![]() |
|
|
|||||||
![]() |
![]() |
![]() |
![]() |
Mark Forums Read |
| Programming :: Programming related discussions :: |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|
![]() Code:
#include <iostream>
using namespace std;
// Leave this class unchanged.
class cDriver {
public:
int age;
int license;
};
// you can edit this function.
cDriver* myFunc() {
cDriver D;
cDriver* pD = &D;
pD->age = 27;
return pD;
}
// you can edit below main, with the desired output.
int main(int argc, char *argv[])
{
cDriver* d;
d = myFunc();
cout << d->age << endl;
cout << "Display Age: " << d->age << endl;
d->age = 27;
d->license = 4413;
cout << "age: " << d->age << endl;
cout << "gpa: " << d->license << endl;
system("PAUSE");
return 0;
}
Code:
27 Display Age: 0 age: 0 gpa: 104724280 Press any key to continue . . . Code:
27 Display Age: 27 age: 27 gpa: 4413 Press any key to continue . . . I don't know what's the difficulty level of this problem, just try to solve it. GOODLUCK...! |
|||||
|
#2
|
|
#5
|
|
Code:
int main(int argc, char *argv[])
{
cDriver d;
cDriver* pd = myFunc();
d = *pd;
cout << d.age << endl;
cout << "Display Age: " << d.age << endl;
d.age = 27;
d.license = 4413;
cout << "age: " << d.age << endl;
cout << "gpa: " << d.license << endl;
system("PAUSE");
return 0;
}
|
|||||
|
#6
|
|
@nullpointer,
you did a great job hope you can explain a bit., :P is it accidentally discover? hoping your honest share 2-3 of my collegues code it that why, BUT, there's still an issue right there, still had some bugs and overhead.I wonder why you didn't use the "->" operator. can you resolve using both (dot) and "->" operator? eg. cout << d.age; cout << pd->age; again, nice try...
|
||||
|
#8
|
|
you almost got it anyway on this kind of solution.
|
|||||
|
#9
|
|
if ever you will forget this rule.
|
|||||
|
#10
|
|
I don't know C++ but know a little C and Java. Here's my solution.
With a big help from Stack Overflow. |
|||||
|
#11
|
|
![]() i thought this is a guessing game! lewlz. shame on me. |
||||||
|
#12
|
|
or anyone can give using malloc?
Last edited by MarkCuering; 10-15-2009 at 07:21 AM.
|
|||||
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A hard headed boy, know how to solve his problem? | mr_kyme | Family Matters | 21 | 09-18-2009 09:27 AM |
| solve weight problem...i can help you through | tabsy | Fitness & Health | 3 | 06-12-2006 07:18 PM |
| VB gurus... I need your expertise... problem solve | afortaliza | Programming | 14 | 05-23-2006 09:38 PM |
| PROBLEM SOLVE ****mods pls close**** | koto | Computer Hardware | 5 | 12-27-2005 08:42 PM |