C++ help

Get help on programming - C++, Java, Delphi, etc.
Post Reply
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

C++ help

Post by DarkRanger »

Hi guys,

I'm looking for the best possible way to learn C++. I have experience in Java programming, so I would like something that looks at C++ with Java as a background.

I know of a book called C++ for Java programmers, but I am also interested in online resources. If you know of any, PLEASE give me a shout!!

Thanks! :)
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: C++ help

Post by RuadRauFlessa »

Best thing would be to forget everything you have learned in Java. Take it from someone that needed to do the migration himself. If you don't you will shoot yourself in the foot with assumptions. Rather learn the language from scratch. From Java the only one you can take up with relative ease in terms of how it works and what there is to work with is C#.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: C++ help

Post by DarkRanger »

Forgetting Java will make me fail next semester! :lol:

But I get what you are saying. Any good articles you can point me to for the beginner? I tried googling, but you get so many claims of code that will turn you into a genius, and I don't know which to trust.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: C++ help

Post by RuadRauFlessa »

:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Re: C++ help

Post by rustypup »

RuadRauFlessa wrote:Best thing would be to forget everything you have learned in Java.
i disagree... java coding habits are an excellent base to work from ...

single inheritance
OOAD
event handling
MVC

c++ will add to DarkRanger's toolkit by introducing:
the preprocessor
memory management and a deeper understanding of leaks and garbage collection..
the power of pointers
a better understanding of reference, value and scope...
real structs...
the joy of operator overloading
multiple inheritance, (and why it's not as good as it sounds)

amongst others...


@DarkRanger: your class design undergoes a paradigm shift because each class is split into 2 files, which means your class template and its implementation don't reside side-by-side as they do in java.

each object you design will need an implicit constructor and destructor, (the java compiler would typically create these for you if omitted)

aside from that, it is worth the effort to go back to basics for now... C++ Tutorial is as good as any starting point... pay attention to pointers, namespaces and scope... these are the high bug producing areas of the language...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: C++ help

Post by RuadRauFlessa »

I did not mean forget how to code. Just the language. How to code you will always need and the more langs you know the easier it will be to go to the next one.
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Re: C++ help

Post by rustypup »

RuadRauFlessa wrote:I did not mean forget how to code. Just the language.
ahh... got you... will apply more coffee posthaste... :oops:
Most people would sooner die than think; in fact, they do so - Bertrand Russel
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: C++ help

Post by DarkRanger »

Thanks for the help guys.

I'll ask again if something comes up.
Image
RuadRauFlessa
Registered User
Posts: 20576
Joined: 19 Sep 2003, 02:00
Location: Bloodbank

Re: C++ help

Post by RuadRauFlessa »

DarkRanger wrote:Thanks for the help guys.

I'll ask again if something comes up.
NP. Just shout around here somewhere and someone is bound to hear it :wink:
:rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock: :rock:
Spoiler (show)
Intel Core i7-2600k @ 3.4GHz
Corsair Vengence 2x4GB DDR3 2000MHz
Thermaltake Toughpower 850W
ASUS nVidia GTX560 1GB
CoolerMaster HAF 932
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: C++ help

Post by DarkRanger »

Okay, I must be doing something stupid, as I googled the error and I couldn't find an error similar to mine.

Here is my source code:

Code: Select all

#include <iostream>
using namespace std;

int main(int argc, char** argv)
{
	if(argc < 4)
		cout<<"ERROR - Too few arguments passed. Correct usage is ./cos121_prac1 x y z where x y z are positive integers."<<endl;
	else if(argc > 4)
		cout<<"ERROR - Too many arguments passed. Correct usage is ./cos121_prac1 x y z where x y z are positive integers."<<endl;
	else
		cout<<"ENOUGH ARGUMENTS PASSED"<<endl;
}
This is my makefile code:

Code: Select all

cos121_prac1 : main.o
	g++ -static -main.o -o cos121_prac1

main.o : main.cpp
	g++ -static -c main.cpp -o main.o

clean:
	rm main.o cos121_prac1
And here is the error I am getting when I enter make cos121_prac1

Code: Select all

g++ -static -c main.cpp -o main.o
g++ -static -main.o -o cos121_prac1
g++: no input files
make: *** [cos121_prac1] Error 1
Any suggestions to what I might be doing wrong?
Image
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: C++ help

Post by DarkRanger »

any help? :cry:
Image
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Re: C++ help

Post by rustypup »

g++: no input files
the compiler is telling you exactly what the issue is... given that it didn't belch during compilation, we have only to glance at:
g++ -static -main.o -o cos121_prac1
to find the suspect...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: C++ help

Post by DarkRanger »

rustypup wrote:
g++: no input files
the compiler is telling you exactly what the issue is... given that it didn't belch during compilation, we have only to glance at:
g++ -static -main.o -o cos121_prac1
to find the suspect...
bows head in shame. Thanks rusty. It works now...
Image
Post Reply