undeclared identifier "class"
-
The majority of the project files are .c, written a long, long time ago. I've been assigned to maintain and add a few new features. My goal was to make the newer features more object oriented as opposed to millions of structs that the old code was using. I could always give up and continue adding to the endless amount of structs, but I wanted to begin adding more object oriented techniques and get away from some of the older c stuff.
[Insert Witty Sig Here]
VonHagNDaz wrote:
The majority of the project files are .c,
Which may be why the compiler is complaining about the
class
keyword."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
VonHagNDaz wrote:
The majority of the project files are .c,
Which may be why the compiler is complaining about the
class
keyword."Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Aren't most compilers smart enough to cross compile c and c++ files in the same project, or am I confused?
[Insert Witty Sig Here]
-
Aren't most compilers smart enough to cross compile c and c++ files in the same project, or am I confused?
[Insert Witty Sig Here]
There's nothing wrong with having .c and .cpp files in the same project.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Aren't most compilers smart enough to cross compile c and c++ files in the same project, or am I confused?
[Insert Witty Sig Here]
I suppose they're smart enough to consider
*.c
files asC
sources, while*.cpp
ones asC++
sources. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
I suppose they're smart enough to consider
*.c
files asC
sources, while*.cpp
ones asC++
sources. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
I suppose they're smart enough to consider *.c files as C sources, while *.cpp ones as C++ sources.
correct, but what I'm trying to do is make a class in a .cpp file. Long story short I gave up and I'm using structs now, but structs cant have member functions, so I'm confused. I've only been exposed to OOP in c++, and I've poked c with a 10 foot pole once. I need member functions for the struct, or is that strictly c++ OOP? Google isn't turning up much when I search for member functions for structs, I'm guessing this is a lost cause as well. dumb programming question #2 : If I was trying to make a more object oriented approach in c, where would I begin? That might be a basic question, but if you've been reading, all my attempts so far have failed, or are wrong... moral : Colleges need more classes on just c and non OOP approaches. In school we had 10+ c++ OOP classes, and one c class where they said "This is c, no one uses it anymore, but now you've been exposed to it..."
[Insert Witty Sig Here]
-
CPallini wrote:
I suppose they're smart enough to consider *.c files as C sources, while *.cpp ones as C++ sources.
correct, but what I'm trying to do is make a class in a .cpp file. Long story short I gave up and I'm using structs now, but structs cant have member functions, so I'm confused. I've only been exposed to OOP in c++, and I've poked c with a 10 foot pole once. I need member functions for the struct, or is that strictly c++ OOP? Google isn't turning up much when I search for member functions for structs, I'm guessing this is a lost cause as well. dumb programming question #2 : If I was trying to make a more object oriented approach in c, where would I begin? That might be a basic question, but if you've been reading, all my attempts so far have failed, or are wrong... moral : Colleges need more classes on just c and non OOP approaches. In school we had 10+ c++ OOP classes, and one c class where they said "This is c, no one uses it anymore, but now you've been exposed to it..."
[Insert Witty Sig Here]
Only
C++
structs allow member functions (C++ struct
s are just classes with different default visibility rules). Maybe I missed a point: if you needOOP
, while are you usingC
language?VonHagNDaz wrote:
If I was trying to make a more object oriented approach in c,
Use
C++
.C
language is best suited for structured programming. There's nothing wrong in following structured programming paradigm: for small projects it is a winning approach. On the other hand, if you need to exploitOOP
advantages, you should use an object oriented language, suchC++
. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Only
C++
structs allow member functions (C++ struct
s are just classes with different default visibility rules). Maybe I missed a point: if you needOOP
, while are you usingC
language?VonHagNDaz wrote:
If I was trying to make a more object oriented approach in c,
Use
C++
.C
language is best suited for structured programming. There's nothing wrong in following structured programming paradigm: for small projects it is a winning approach. On the other hand, if you need to exploitOOP
advantages, you should use an object oriented language, suchC++
. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
while are you using C language?
all of the source is in c. This is a massive amount of code I'm maintaining and adding new features to. I thought that I could use .cpp classes, include the .h files in the .c files, and access the object's member functions through pointers. The approach made sense to me, but I guess I'm stuck with c structs and no member functions.
[Insert Witty Sig Here]
-
CPallini wrote:
while are you using C language?
all of the source is in c. This is a massive amount of code I'm maintaining and adding new features to. I thought that I could use .cpp classes, include the .h files in the .c files, and access the object's member functions through pointers. The approach made sense to me, but I guess I'm stuck with c structs and no member functions.
[Insert Witty Sig Here]
Why don't you upgrade to
C++
(i.e. rename from.c
to.cpp
) the files wherein you want to use classes? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Why don't you upgrade to
C++
(i.e. rename from.c
to.cpp
) the files wherein you want to use classes? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke:doh: Why are the simplest answers the hardest to find? [Insert Witty Sig Here]
-
:doh: Why are the simplest answers the hardest to find? [Insert Witty Sig Here]
Often posting the right question is difficult. :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke