Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Apr 26th, 2006, 6:47 PM   #11
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
Ok,.. how did u compile it?
I did it like this.
1) Copy and pasted the code as it is in parts, and saved it as mentioned above. (ListType.h, listTypeImp.cpp, test.cpp)
2) Saved those files in a folder.
3) Then opened the file test.cpp in BORLAND and pressed the compile button.

That is it. and then ofcourse got an error.
Mack1982 is offline   Reply With Quote
Old Apr 26th, 2006, 7:02 PM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Consider for a moment that you have more than one source file. Believe it or not, housing them in the same directory does not magically cause your compiler to know that you want them to be part of the final executable. Make a console project and add all three files to it. Use your help documentation or farble around; time to break some sweat here. Once they are specified as forming a project, build the project. When you've got a little time for a break, research the steps that are necessary to get from textual code files to a running executable. Preprocessing, compiling, linking, blah blah blah. Relying on your prof seems problematic.
__________________
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 Apr 26th, 2006, 7:04 PM   #13
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
0xcafedead eh? I stick by 0xdeadbeef.

Wouldn't that imply that either a pointer somewhere has been specifically set to 0xcafedead as a debugging aid? In Wine (which is not an emulator, by the way) any not-implemented functions are fixed-up to 0xdeadbeef. That way, a crash relating directly to a non-implemented function is easy to discern from something more sinister. Just a thought. Any compiler/linker errors/warnings?
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Apr 26th, 2006, 11:31 PM   #14
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
OK thank you guys for encouragement,.. I got the answer.
Special Thanks DaWei, your console project method worked. I had to study for it but in the end i think 15 minutes were worth the trouble.
I think u will see more posts from me in the future,..lol
Mack1982 is offline   Reply With Quote
Old Apr 27th, 2006, 4:42 AM   #15
Seif
Hobbyist Programmer
 
Seif's Avatar
 
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3 Seif is on a distinguished road
I know DaWei thats why I had just kidding at the end of my post. Makes me wonder about some of these CS lecturers who teach stuff like this :/
Seif is offline   Reply With Quote
Old Apr 29th, 2006, 1:31 AM   #16
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Seif
I know DaWei thats why I had just kidding at the end of my post. Makes me wonder about some of these CS lecturers who teach stuff like this :/
Yeah, it's like my prof some semesters back who used to always remind the students to "#include your library files". It made me cringe every time I heard that.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Apr 30th, 2006, 12:44 AM   #17
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
you also employed information hiding in your post by hiding the code somewhere else. i have dial-up, i'm not gonna click on that shit.

anyway, when i use information hiding i typically have my compiler count to 100 while i hide the code in a cardboard box. once i hid a private member function under my porch and gcc didn't find it for three days, then i let vs have a try at it. it was a jolly old time.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Apr 30th, 2006, 4:49 AM   #18
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
Lets say that I have to make a derived class from the above mentioned one.
Do I just add to the current project console the new .h and .cpp files or is there some other way?
Mack1982 is offline   Reply With Quote
Old Apr 30th, 2006, 5:53 AM   #19
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by Mack1982
Lets say that I have to make a derived class from the above mentioned one.
Do I just add to the current project console the new .h and .cpp files or is there some other way?
If the classes (base and derived) are tightly coupled (perhaps if the base is abstract, and you want one or more derived implementations), it may make sense to have them in the same file. That said, if you choose to put them in different files, then yes, you merely need to add them to the project. It helps if they are in the same directory as the other source files, but this isn't a requirement.

Remember, the 'project' is merely a set of rules (compiler/linker options, and so on) to use when building your program, and a list of files to use (source, object, and library). You shouldn't need to add your header files to the project, as they are #included by your code, but you will need to add your C++ source files.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old Apr 30th, 2006, 10:00 AM   #20
Mack1982
Programmer
 
Join Date: Dec 2004
Posts: 34
Rep Power: 0 Mack1982 is on a distinguished road
Let me give an example of what i am doing:
The base class is called Two_Dimensions. I have included three files in this project namely:
1) Two_Diemensions_Header.h (Contains header file)
2) Two_Diemensions_Main.cpp (The MAIN function)
3) Two_Diemensions_Imp.cpp (The Implememtation of the class Function)

Now I need to create a new derived class called Rectangle, which takes the Two_Dimensions from the above (length and width) class, adds a new variable Height to it and then display various things like Area, paramenter etc,.
So, do it just add the three files (Rectangle_Header.h, Rectangle_Main.cpp, Rectangle_Imp.cpp) to the Two_Diemension project that already exists or do i make a new project and add the Two_Dimension Header and Implementation file only and the entire Derived Class Rectangle.

In SHORT The first false would include one project with Six Files:
1) Two_Dimensions_Header.h
2) Two_Dimensions_Imp.cpp
3) Two_Dimensions_MAIN.cpp
4) Triangle_Header.h
5) Triangle_Imp.CPP
6) Triangle_MAIN.CPP

The second case would be that I make a new Project called Rectangle and ADD only TWO Files from the Base Class Two_Dimensions. Overall the project would contain the following files:
1) Two_Dimensions_Header.h
2) Two_Dimensions_Imp.cpp
3) Triangle_Header.h
4) Triangle_Imp.CPP
5) Triangle_MAIN.CPP

NOTE: No main function for Two_Dimensions.
Mack1982 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:02 PM.

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