Advertisement
Advertisement
| 05.05.2008 at 09:09AM PDT, ID: 23376794 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: |
void fruitType::setFruit(char **fruits)
{
char** start, **end;
for (start = fruits, end = &fruits[3]; start <= end; start++)
strcpy(*FRUIT, *start);
}
|
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 05.05.2008 at 10:23AM PDT, ID: 21501480 |
| 05.05.2008 at 05:16PM PDT, ID: 21503960 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: |
#include <iostream>
using namespace std;
void addFruit();
const int fruitSize = 40;
class fruitType
{
public:
fruitType(); //default constructor: allocate new d.m.
//set functions
void setFruitInfo(char**);
void setFruits(char**); //set Fruits' name
char* getFruits() const; //return Fruits' name
void showFruits() const; //display Fruits' name
private:
char *Fruits[3]; //Fruits pointer
}; //end class fruitType
fruitType::fruitType()
{
for ( int i = 0; i < 3; i++)
{
try
{
Fruits[i] = new char[fruitSize];
memset(Fruits[i],'\0',sizeof(char)*fruitSize);
}
catch (bad_alloc b)
{
cout << "Could not allocate Fruits in dynamic memory." << endl;
exit(1);
}
}
}//end function fruitType::fruitType
//modifying the data members by passing input to their respective function
void fruitType::setFruitInfo(char** Fruits)
{
setFruits(Fruits);
}//end function fruitType::setFruitInfo
void fruitType::setFruits(char **Fruits)
{
char** start, **end;
for (start = Fruits, end = &Fruits[2]; start <= end; start++)
{
cout << "..........";
strcpy(*Fruits, *start);
}
}
char* fruitType::getFruits() const //return fruit
{
for ( int i = 0; i < 3; i++)
return Fruits[i];
}//end function fruitType::Fruits()
void fruitType::showFruits() const //display Fruits
{
for ( int i = 0; i < 3; i++)
cout << Fruits[i];
}//end function fruitType::showFruits
int main()
{
addFruit();
system("PAUSE");
return 0;
}
void addFruit()
{
fruitType a; //declare an object of fruitType
char *Fruits[3];
char **startA, **endA;
//allocate dynamic memory for 4 Fruits
try
{
for (startA = Fruits, endA = &Fruits[2]; startA <= endA; startA++)
*startA = new char[fruitSize];
}
catch (bad_alloc b)
{
cout << "Could not allocate memory to Fruits.";
exit(1);
}
cout << "---------Add Fruit---------" << endl;
int count = 1; //use to display fruit position
//input up to 4 Fruits
for (startA = Fruits, endA = &Fruits[2]; startA <= endA; startA++)
{
cout << "Enter Fruit " << count << " : "; //e.g Australian Mango
cin.getline(*startA, fruitSize);
count++;
}
a.setFruitInfo(Fruits);
a.showFruits();
}//end of addFruit function
|
| 05.05.2008 at 10:39PM PDT, ID: 21504964 |
| 05.05.2008 at 10:49PM PDT, ID: 21504996 |
| 05.05.2008 at 11:38PM PDT, ID: 21505155 |
| 05.05.2008 at 11:42PM PDT, ID: 21505171 |
| 05.08.2008 at 05:06PM PDT, ID: 21529527 |
| 05.08.2008 at 05:43PM PDT, ID: 21529655 |
| 05.08.2008 at 10:19PM PDT, ID: 21530523 |
| 05.08.2008 at 10:37PM PDT, ID: 21530569 |
| 05.09.2008 at 09:18AM PDT, ID: 21534353 |
| 05.10.2008 at 06:10AM PDT, ID: 21538916 |
| 05.10.2008 at 06:47AM PDT, ID: 21539034 |