![]() |
Misc C++ things I have trouble understanding
I find myself asking myself certain questions when I am programming C++. When I consult textbooks, I often find the answers cryptic, or over simplified. Lately, I have been experimenting with pointers and OOP.
I'll start with OOP. Here, I've written a program that declares a class for some of the properties of a gem, creates a gem named "bob", and within the main function, the characteristics for bob are declared then echoed back. Code:
//********************************* Code:
--------------------Configuration: oop - Win32 Debug-------------------- I guess I seem like a C++ n00b, but we all have to start somewhere, I guess. |
Re: Misc C++ things I have trouble understanding
You need to change "Class" to "class".
If you look carefully at the errors ( Specifically #1 ) that the compiler has outputted you'll see what's wrong. All C++ keywords are case-sensitive so typing Class or Struct is not the same as class or struct. |
Re: Misc C++ things I have trouble understanding
"Class" must have a lower case 'c' so it should be "class" and not "Class" :)
|
Re: Misc C++ things I have trouble understanding
lol :D damnit got there before me 8D
|
Re: Misc C++ things I have trouble understanding
ugh, one shift key mix-up, and three errors sprout up. I thought class was uppercase because they are uppercase in Botman's C++ tutorial...
damn shift key.... damn. |
Re: Misc C++ things I have trouble understanding
it looks like the reason for the three errors is 1: because of class being written with a uppercase 'C' . error 2: the compiler gets confused cause when you used the uppercase C it probably thinks you are declaring a variable with Class as a type and wants the ; to end the sentence. error 3 is probably due to line 17 being an invalid code. Am I on the right track?
MusicMan |
Re: Misc C++ things I have trouble understanding
also remember that everything is case sensitive in C/C++, even filenames. Micro$oft visual studio does not correctly handles file names (create some project and see: stdafh.h is name of file and in source code, Visual .NET types #include <StdAfx.h> which of course will rin on Windows(tm) machines but won't even compile on Linux)
|
Re: Misc C++ things I have trouble understanding
Quote:
|
Re: Misc C++ things I have trouble understanding
I disagree: at least MSVC 6 doesn't care about the case in the include files...
|
Re: Misc C++ things I have trouble understanding
theres something about the MSVC6 compiler i hate..
i think its all the extra crap they put in a program that gcc doesn't do. |
All times are GMT +2. The time now is 06:02. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.