Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-18-2007, 12:49 AM
Lestat's Avatar   
Lestat Lestat is offline
Newbie
 
Join Date: Sep 2007
Location: Belize
Posts: 9
Rep Power: 0
Lestat is on a distinguished road
Send a message via ICQ to Lestat Send a message via MSN to Lestat Send a message via Yahoo to Lestat
Default Assignment

I just wanted help on doing this work i was given in my classroom.... I dont really get the "class/classes" for C++

Quote:
3.) (Modifying Class GradeBook) Modify class GradeBook as follows:
a. Include a second string data member that represents the course instructor's name.
b. Provide a set function to change the instructor's name and a get function to retrieve it.
c. Modify the constructor to specify two parametersone for the course name and one for the instructor's name.
d. Modify member function displayMessage such that it first outputs the welcome message and course name, then outputs "This course is presented by: " followed by the instructor's name.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-18-2007, 09:01 AM
kkelly's Avatar   
kkelly kkelly is offline
Learning Programmer
 
Join Date: Sep 2007
Posts: 50
Rep Power: 5
kkelly is on a distinguished road
Default

Classes put the object in "Object Oriented Programming". There is a decent article here C++ Tutorial - class. It covers everything you'll need to get you going.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-18-2007, 10:04 AM
Lestat's Avatar   
Lestat Lestat is offline
Newbie
 
Join Date: Sep 2007
Location: Belize
Posts: 9
Rep Power: 0
Lestat is on a distinguished road
Send a message via ICQ to Lestat Send a message via MSN to Lestat Send a message via Yahoo to Lestat
Default

Thanks for the link kkelly. But its rather short. I wanted something maybe more larger with more example and definition so i can really get the "gist" of it. Thanks for the help anyways .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-18-2007, 10:24 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

There's many tutorials on the internet.

This will might help you a little too:
Code:
class SomeClass
{
	private:
		std::string Name1;
		std::string Name2;
	public:
		SomeClass()
		{
			this->Name1 = "";
			this->Name2 = "";
		}
		
		SomeClass(std::string FirstName, std::string SecondName = "")
		{
			this->Name1 = FirstName;
			this->Name2 = SecondName;
		}
		
		void Display()
		{
			std::cout << "Name1: " << Name1 << std::endl;
			std::cout << "Name2: " << Name2 << std::endl;
		}
		
		void SetNames(std::string FirstName, std::string SecondName)
		{
			this->Name1 = FirstName;
			this->Name2 = SecondName;
		}
		
		std::string GetName1()
		{
			return this->Name1;
		}
		
		std::string GetName2()
		{
			return this->Name2;
		}
};
Not the best class design, but this class uses everything you need. I didn't wanted to make the correct, because you should do something as well (;-)
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-18-2007, 10:52 AM
Lestat's Avatar   
Lestat Lestat is offline
Newbie
 
Join Date: Sep 2007
Location: Belize
Posts: 9
Rep Power: 0
Lestat is on a distinguished road
Send a message via ICQ to Lestat Send a message via MSN to Lestat Send a message via Yahoo to Lestat
Default

If i get a error that says
Quote:
" [Linker error] undefined reference to `WinMain@16'" ld returned 1 exit status
new error

Last edited by Lestat; 09-18-2007 at 10:56 AM. Reason: New Error
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 09-18-2007, 11:07 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

You can't compile what I posted. What I posted was only a class, not a whole program. It was meant as some code you could use parts of, for what you want to do.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-18-2007, 01:32 PM
Lestat's Avatar   
Lestat Lestat is offline
Newbie
 
Join Date: Sep 2007
Location: Belize
Posts: 9
Rep Power: 0
Lestat is on a distinguished road
Send a message via ICQ to Lestat Send a message via MSN to Lestat Send a message via Yahoo to Lestat
Default

I no..... i made a driver and a .h file already but i am still getting errors i will try something else. I am having problem making the Source File.... what all should i have in it?

Last edited by Lestat; 09-18-2007 at 02:47 PM. Reason: Update
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-18-2007, 03:15 PM
kkelly's Avatar   
kkelly kkelly is offline
Learning Programmer
 
Join Date: Sep 2007
Posts: 50
Rep Power: 5
kkelly is on a distinguished road
Default

I guess you can look at classes from a couple perspectives, the compiler and the programmer's.
To a compiler a class is a data type that contains data and all the functions that are necessary to access and manipulate that data. The data and the functions make up the class members. The class declaration and all member declarations are written in a header file (.h). All members of a class belong to an access scope. An access scope is like a security container. Access scopes are compiler specific, but ones to remember are private, protected, and public. Private members can only be accessed by members of the same class. Protected members can only be accessed by members of the same class and its derived (child) classes. Public members have no access restrictions. Class functions are written in a source file (.cpp). The source file must contain a #include statement that links it to the header file.
In c++, classes come with a few built-in features. There are two functions that are implied in a class definition. They are the constructor and destructor. Whenever a class is instantiated the constructor is called and creates an instance of the class, or object of the class. Whenever an instantiated class (object) is removed from memory its destructor is called. The constructor can be overloaded (declared with a different parameters). To use the overloaded constructor when instantiating the class, you'll have to call it explicitly.
To a programmer, a class provides a added layer of abstraction that provides encapsulation and modularity. You may be familiar with the term "black-box" technology. It means that you don't need to know how the device works. All you know is whenever you put something in you'll get something out. Kind of like in the cartoons where there will be a conveyor belt and an enclosure. Where some raw material, or character, goes into the enclosure, it comes out as some finished product. What happens in the enclosure we don't need to know. The enclosure is the "black-box", or object. The blue-print for the object is the class.
But say you want the raw material to not just come out as some finished product, but to also be packaged and ready to ship. Do we have to redesign our enclosure? Nope, just write a blue-print for a machine that takes our finished product and packages it, build the machine (instantiate the class), and connect the two. Not only did you not have to rewrite your original blue-print, but if something goes wrong, you can quickly track it down by examining the product as it passes between machines (objects) and re-write only the blue-print (class) that contains the error.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 09-18-2007, 03:20 PM
Lestat's Avatar   
Lestat Lestat is offline
Newbie
 
Join Date: Sep 2007
Location: Belize
Posts: 9
Rep Power: 0
Lestat is on a distinguished road
Send a message via ICQ to Lestat Send a message via MSN to Lestat Send a message via Yahoo to Lestat
Default

Ok..... thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Post your funny jokes/brain teasers here littlefranciscan The Lounge 181 02-02-2008 02:06 AM
NEED C++ Assignment HELP URGENT! Sakinah C and C++ 7 08-06-2007 01:42 PM


All times are GMT -5. The time now is 02:02 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads