C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 19th, 2006, 10:51 PM
jandali jandali is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 18 jandali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 6 m 23 sec
Reputation Power: 0
Need some help with one function

// sets the student last name to lastName.
void setLastName(char* lastName);

this function put the new name into the lastname list, i don't know where to start?

Reply With Quote
  #2  
Old February 20th, 2006, 02:53 AM
Icon's Avatar
Icon Icon is offline
Command Line Warrior
Click here for more information. Click here for more information
 
Join Date: Sep 2005
Posts: 739 Icon User rank is Private First Class (20 - 50 Reputation Level)Icon User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 3 Days 12 h 29 m 29 sec
Reputation Power: 4
With this much information we cannot start either Please elaborate a little bit more on your problem. Do you already have any code? Does this last name list already exist? Is it c or c++?

Reply With Quote
  #3  
Old February 20th, 2006, 06:47 PM
jandali jandali is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 18 jandali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 6 m 23 sec
Reputation Power: 0
code Code:
Original - code Code
    ifndef _STUDENTREC_H #define _STUDENTREC_H #define NUM_OF_MARKS 5   // indexed 0-4 class studentRecord { private:     unsigned int studentNumber;     char* _firstName;         char* _lastName;     unsigned int marks[NUM_OF_MARKS]; public:     // the default constructor     studentRecord();     // the destructor     ~studentRecord();      // sets the student number of the record to studentNum.     void setStudentNumber(unsigned int studentNum);     // sets the student first name to firstName.     void setFirstName(char* firstName);     // sets the student last name to lastName.     void setLastName(char* lastName);     // sets the mark at index "index" of the student record to mark.     // the method assumes the index is in 0-4 range, and     // the mark is in 0-100 range.     void setMark(int index, unsigned int mark);     // returns the student number.     unsigned int getStudentNumber();     // returns a pointer to the first name of the student record.     char * getFirstName();     // returns a pointer to the last name of the student record.     char * getLastName();     // returns the mark at index "index" of the student record.     // it assumes the index is in 0-4 range.     unsigned int getMark(int index);     // prints the student record to the standard output in the format     // specified in the assignment specifications.     void print(); }; //studentRecord #endif

Reply With Quote
  #4  
Old February 20th, 2006, 09:23 PM
r.3volved r.3volved is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 5 r.3volved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 6 m 49 sec
Reputation Power: 0
I don't think I understand....are you only doing this?:

Code:
void setLastName( char* lastName )
{
  _lastname = lastName;
}

Reply With Quote
  #5  
Old February 21st, 2006, 12:29 AM
jandali jandali is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 18 jandali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 6 m 23 sec
Reputation Power: 0
Quote:
Originally Posted by r.3volved
I don't think I understand....are you only doing this?:

Code:
void setLastName( char* lastName )
{
  _lastname = lastName;
}

yes i guess so, but are we suppose to write any code in the default constructor

Reply With Quote
  #6  
Old February 21st, 2006, 12:35 PM
r.3volved r.3volved is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2006
Posts: 5 r.3volved User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 6 m 49 sec
Reputation Power: 0
Only if you want the constructor to set any default values

thats why you can overload methods...

StudentRecord()

or..
Code:
StudentRecord(string lastname, string firstname)
{
  _lastname = lastname;
  _firstname = firstname;
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Need some help with one function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT