![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programmer
Join Date: Dec 2004
Posts: 34
Rep Power: 0
![]() |
//Implmentation
#include "first.h"
#include <iostream>
using namespace std;
first::first(char n[])
{
strcpy(fName,n);
}
void first::setName(char n[])
{
for (int i=0;i<20;i++)
fName[i] = n[i];
}
char* first::getName()
{
return fName;
}First.h ifndef H_First
#define H_First
class first
{
public:
first(char[]);
char* getName();
void setName(char[]);
private:
char fName[20];
}
#endif#include "first.h"
#include <iostream>
using namespace std;
int main()
{
first MyName("Mansoor");
char* TheName = MyName.getName();
cout << "n " << TheName << endl;
return 0;
}I dont see sal.h inclusion anywhere, coud someone check this code by compiling and see if they get the same error. I am guess could be some kind of setting problem perhaps,.... I think i read the rules but i forgot,... because I learned that code tag thingy from there,,.... anyway will be careful next time,.. |
|
|
|
|
|
#22 |
|
Programmer
Join Date: Jun 2005
Posts: 99
Rep Power: 4
![]() |
Apart from the missing semi-colon at the end of class first everything looks fine.
|
|
|
|
|
|
#23 |
|
Programmer
Join Date: Dec 2004
Posts: 34
Rep Power: 0
![]() |
Are u sure there should be a semi colon after the class First,..
u mean like this,.. class first;
{
public: |
|
|
|
|
|
#24 |
|
Programmer
|
No, he means
class First
{
/* your class here */
};As for sal.h, it's used internally by most headers shipped with Visual C++. |
|
|
|
|
|
#25 |
|
Programmer
Join Date: Dec 2004
Posts: 34
Rep Power: 0
![]() |
Bingo man,.. U were right,.. the ; was the problem,.. it is fine now,..
But even then a very strange error for missing a ; |
|
|
|
|
|
#26 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Yes, that is strange, the message, "missing ;" for a missing ;.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#27 |
|
Programmer
Join Date: Dec 2004
Posts: 34
Rep Power: 0
![]() |
Ok the final part of the project which is a little trouble some,..
lets say that the following is the way a MAIN looks: #include<iostream> #include "employee.h" #include "List.h" //a link list class list myList(); the list has the following functions: class List
{
Node* first;
int count;
public:
List();
bool insert(Employee& s);
int size();
void display();
Employee& operator[](int n);
~List();
};
]Thanks |
|
|
|
|
|
#28 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
How about a loop that runs five (or however many) times, then gracefully retires to the country for the summer?
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
|
#29 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
Yeah, a loop is the way to go. And look into the standard, built in List library. It'll save you some time, and you won't have to worry about stuff going wrong with your list coding.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|