|
-
October 18th, 2007, 04:03 AM
#1
Classname vs. Filename
Hi,
when I create a class I chose the filename to be the same as the class name. Is that a must? What about capital/small letters? Can the filename all in small letters but the class name can be SomeThing with small and capital letters?
Thanks,
J.
-
October 18th, 2007, 04:12 AM
#2
Re: Classname vs. Filename
it is not a must that the class name(i think you mean the header file name) be the same as the file name , also it does not have to be in capital letters.
there is ni relation between the header file name and the original file name.
but if you come to programming using JAVA it is amust.
-
October 18th, 2007, 07:22 AM
#3
Re: Classname vs. Filename
It's not a must to name the classes and files the same, but when you get big projects with hundreds of classes and files, it'll certainly come in handy.
-
October 18th, 2007, 06:46 PM
#4
Re: Classname vs. Filename
One last question:
I understand that I can name the .h file as I want. Since it is known via include it is no problem to find that file. The implementation of my constructor and other functions is in a .cpp file, how is that found? I assume that the .h and the .cpp must have the exact same name. Is that correct?
-
October 18th, 2007, 07:31 PM
#5
Re: Classname vs. Filename
 Originally Posted by joebar
One last question:
I understand that I can name the .h file as I want. Since it is known via include it is no problem to find that file. The implementation of my constructor and other functions is in a .cpp file, how is that found? I assume that the .h and the .cpp must have the exact same name. Is that correct?
No. The file names really don't mean anything to the compiler and linker. Consistent and practical naming is done to help make the programmer's job easier.
-
October 19th, 2007, 09:48 AM
#6
Re: Classname vs. Filename
Okay but let's assume I have
main.cpp
aClass.h
MyClass.cpp
and a class called superClass. The compiler finds the header via the include, so aClass.h is found from main.cpp. How does the compiler know that the implementation of the superClass is found in MyClass.cpp?
-
October 19th, 2007, 10:02 AM
#7
Re: Classname vs. Filename
You tell it to compile MyClass.cpp and it compiles whatever it finds in there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|