Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 23rd, 2006, 10:29 PM   #21
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
//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,..
Mack1982 is offline   Reply With Quote
Old May 23rd, 2006, 11:01 PM   #22
Animatronic
Programmer
 
Join Date: Jun 2005
Posts: 99
Rep Power: 4 Animatronic is on a distinguished road
Apart from the missing semi-colon at the end of class first everything looks fine.
Animatronic is offline   Reply With Quote
Old May 23rd, 2006, 11:25 PM   #23
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
Are u sure there should be a semi colon after the class First,..
u mean like this,..
class first;
{
 public:
Mack1982 is offline   Reply With Quote
Old May 23rd, 2006, 11:35 PM   #24
niteice
Programmer
 
niteice's Avatar
 
Join Date: Aug 2005
Posts: 98
Rep Power: 4 niteice is on a distinguished road
Send a message via AIM to niteice
No, he means
class First
{
/* your class here */
};
Note the semicolon after the closing brace.


As for sal.h, it's used internally by most headers shipped with Visual C++.
niteice is offline   Reply With Quote
Old May 24th, 2006, 1:26 AM   #25
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
Bingo man,.. U were right,.. the ; was the problem,.. it is fine now,..
But even then a very strange error for missing a ;
Mack1982 is offline   Reply With Quote
Old May 24th, 2006, 6:50 AM   #26
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old May 24th, 2006, 12:57 PM   #27
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
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
Now lets say i make a list object called "MyList"
list myList();
How do i add five employee objects to the list
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();
	
};
]
I tried searching the book,.. but couldn't find an example,..
Thanks
Mack1982 is offline   Reply With Quote
Old May 24th, 2006, 9:15 PM   #28
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
How about a loop that runs five (or however many) times, then gracefully retires to the country for the summer?
Quote:
ets say that the following is the way a MAIN looks:
Watch your terminology. In a C or a C++, that is not the way a MAIN looks. You must be from outta town.
__________________
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
DaWei is offline   Reply With Quote
Old May 26th, 2006, 9:02 PM   #29
Twilight
Programmer
 
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3 Twilight is on a distinguished road
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.
Twilight is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC