• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

Eclipse Compiler

Joined
2/6/09
Messages
10
Points
11
I have just started learning C++ and the book I am using wanted me to create a simple program:

C++:
#include <iostream.h>
using namespace std;
int main() {
cout << "Never fear, C++ is here!";
return 0;
}


When I created a 'class' called "print1.cpp" in Eclipse, it created all this generic code, along with a separate file called print1.h

print1.cpp had the following:

C++:
/*
* print1.cpp
*
* Created on: Jul 6, 2009
* Author: Administrator
*/

#include "print1.h"

print1::print1() {
// TODO Auto-generated constructor stub

}

print1::~print1() {
// TODO Auto-generated destructor stub
}


print1.h had:


C++:
#ifndef PRINT1_H_
#define PRINT1_H_

class print1 {
public:
print1();
virtual ~print1();
};

#endif /* PRINT1_H_ */


I don't understand what's going on at all. I am experienced in JAVA and trying to learn C++ but what does this all mean? When I put my peice of code at the end of the print1.cpp file, there is a warning that comes up stating <iostream> is an unresolved inclusion.

<Please be verbose :)>

Thanks in advance guys!

P.s. Is there another compiler that you guys would recommend that would be easier to learn on?
 
Attach your code to the post or use the 'code' tags and embed your code; that'll make it easier to diagnose the problem
 
Looking at your code and seeing :

#include<iostream.h>

which I am assuming you have copied from the book, I suggest you get a more up-to-date book.

I expect to see :

#include<iostream>

including iostream.h was the old way of doing it, moreover with iostream.h you do not need 'using namespace std'

Eclipse is thought very highly of in the JAVA community, but for C++ there are better alternatives.

Are you using Windows or Linux ?

If you're using Windows, I strongly recommend you swap eclipse for the freely downloadable Visual Studio 2008 ( Express ).

If you're using Linux I strongly recommend using Code::Blocks.
 
Puttable,

Let me start saying your knowledge of Java won't translate easily to the C++ world. The OOD concepts will but that's about it.

You need to get a good book and start with it. I recommend "C++ Primer" by Stanley Lippman or Bruce Eckel "Thinking in C++". You can find the latter free on the Internet.

What Eclipse generated for you was a simple code stub for C++ programs. I really don't know what you question is exactly. Could you be more specific?

one more question, did you just opened Eclipse and try to "swing" it in C++ without any idea of what you were doing? keep in mind C++ is orders of magnitude more complex than Java
 
Shlomi, that's what happen when you work a lot in C++. :)
 
Looking at your code and seeing :
#include<iostream.h>
which I am assuming you have copied from the book, I suggest you get a more up-to-date book.

I expect to see :
#include<iostream>

including iostream.h was the old way of doing it, moreover with iostream.h you do not need 'using namespace std'

The book is the 9th printing from 2009 actually. I got the iostream.h from somewhere else when I was trying to figure out what's going on.

The book u ses the syntax:
#include <iostream>



Eclipse is thought very highly of in the JAVA community, but for C++ there are better alternatives.

Eclipse is excellent for JAVA, I agree wholeheartedly.

Are you using Windows or Linux ?

If you're using Windows, I strongly recommend you swap eclipse for the freely downloadable Visual Studio 2008 ( Express ).

If you're using Linux I strongly recommend using Code::Blocks.

I am using Windows XP and have found the following link:
http://www.microsoft.com/express/download/default.aspx
I suspect you mean "Microsoft Visual C++ 2008 Express Edition"?
For quants, will we ever use C#? And hence need the "Microsoft Visual C# 2008 Express Edition"?
 
Puttable,

Let me start saying your knowledge of Java won't translate easily to the C++ world. The OOD concepts will but that's about it.

You need to get a good book and start with it. I recommend "C++ Primer" by Stanley Lippman or Bruce Eckel "Thinking in C++". You can find the latter free on the Internet.

What Eclipse generated for you was a simple code stub for C++ programs. I really don't know what you question is exactly. Could you be more specific?

one more question, did you just opened Eclipse and try to "swing" it in C++ without any idea of what you were doing? keep in mind C++ is orders of magnitude more complex than Java

I am using C++ Without Fear by Brian Overland, the 9th edition.
http://www.amazon.com/Without-Fear-Beginners-Guide-Makes/dp/0321246950

I was actually thinking of using http://www.amazon.com/gp/product/06..._m=ATVPDKIKX0DER&pf_rd_r=1990HZN820TP3WA9DXNJ but given that it is a tome, I felt it would only destroy my motivation for learning it in a month's time before I head to Cornell's FE program.

My question was essentially that I am trying to run a simple, simple, simple program and Eclipse generated all this miscellaneous garbage that makes no sense to me given my current knowledge of C++. When I try running the line "#include <iostream>" it seems as if Eclipse does not contain this library...

Will "Microsoft Visual C++ 2008 Express Edition" on http://www.microsoft.com/express/download/default.aspx contain a library or will I need to install some add ons or what not?
 
Sorry for all the responses, but I have installed the Visual C++ and tried running the code...here is what happened:

I named the file Ch1_Print1 and when I created the file, the compiler/editor created Ch1_Print.h and Ch1_Print.cpp

Here is the code as follows:
Ch1_Print.h
#pragma once
class
Ch1_Print1
{
public:
Ch1_Print1(
void);
~Ch1_Print1(
void);
};

That is all default code.

Ch1_Print.cpp
#include "Ch1_Print1.h"
Ch1_Print1::Ch1_Print1(void)
{
}
Ch1_Print1::~Ch1_Print1(
void)
{
}
#include <iostream>
using namespace std;
int main(){
cout <<
"Never fear, C++ is here!";
return 0;
}

Where my code is at the end. I no longer have an issue with the iostream library but when I went to compile this simple program, all that was shown at the bottom was as follows:
1>------ Build started: Project: Learning C++, Configuration: Debug Win32 ------
1>Compiling...
1>Ch1_Print1.cpp
1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Learning C++\Learning C++\Debug\BuildLog.htm"
1>Learning C++ - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I tried opening that file and it doesn't really show anything new...
[SIZE=+3]Build Log
Build started: Project: Learning C++, Configuration: Debug|Win32

[SIZE=+2]Command Lines [/SIZE] Creating temporary file "c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Learning C++\Learning C++\Debug\RSP00000222642516.rsp" with contents[/Od /D "_MBCS" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\Ch1_Print1.cpp"]Creating command line "cl.exe @"c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Learning C++\Learning C++\Debug\RSP00000222642516.rsp" /nologo /errorReport:prompt"[SIZE=+2]Output Window [/SIZE] Compiling...Ch1_Print1.cpp[SIZE=+2]Results [/SIZE] Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Learning C++\Learning C++\Debug\BuildLog.htm"Learning C++ - 0 error(s), 0 warning(s)
[/SIZE]Does anyone know what's wrong now? :cry:
 
The book is the 9th printing from 2009 actually. I got the iostream.h from somewhere else

Leave the somewhere else where it is. Sounds like it could be a hindarence


I am using Windows XP and have found the following link:
http://www.microsoft.com/express/download/default.aspx
I suspect you mean "Microsoft Visual C++ 2008 Express Edition"?

I do.

For quants, will we ever use C#? And hence need the "Microsoft Visual C# 2008 Express Edition"?

It is not true that ALL quant teams use C++. I know FO quant teams that use JAVA and teams that use C#. However MOST FO quant teams do use C++. For now I wouldn't bother with C#, it'd be better to concentrate on one language, moreover C++ is a huge and better to spend your time and effort learning it well rather than on learning C# as and not learning C++ so well.
 
I am using C++ Without Fear by Brian Overland, the 9th edition.
http://www.amazon.com/Without-Fear-Beginners-Guide-Makes/dp/0321246950
I have never seen this one.

I was actually thinking of using http://www.amazon.com/gp/product/06..._m=ATVPDKIKX0DER&pf_rd_r=1990HZN820TP3WA9DXNJ but given that it is a tome, I felt it would only destroy my motivation for learning it in a month's time before I head to Cornell's FE program.

I have never used this one either, but it is a different book to Lippman's C++ Primer, which is the one I used.

My question was essentially that I am trying to run a simple, simple, simple program and Eclipse generated all this miscellaneous garbage that makes no sense to me given my current knowledge of C++.

I suspect that it wasn't miscellaneous garbage, but don't use eclipse for C++.


When I try running the line "#include <iostream>" it seems as if Eclipse does not contain this library...

hmmm .... doubtful. iostream is part of the standard C++ library and I cannot think of any reason that it is not installed as part of your compiler suite. unless you have a very old version of the compiler (I assume you are using gcc).


Will "Microsoft Visual C++ 2008 Express Edition" on http://www.microsoft.com/express/download/default.aspx contain a library or will I need to install some add ons or what not?

You will need nothing else, its completely self-contained. A bit later on you may want to install Boost ( at least the smart pointer library), just register that fact, it's not something you need to worry about right now.
 
Puttable, now that you have installed VC++, you need to learn how to use it.

From your post, I can see that you were able to compile the program. To run the program use Ctrl+F5.

BTW, Eclipse would be able to compile your program as well. You will need to read a little bit more about it. Google for Eclipse C++. If that is too much effort, click on this link.

http://tinyurl.com/nxrl4m
 
Sorry for all the responses, but I have installed the Visual C++ and tried running the code...here is what happened:

I named the file Ch1_Print1 and when I created the file, the compiler/editor created Ch1_Print.h and Ch1_Print.cpp

Here is the code as follows:
Ch1_Print.h
..code snipplet ..
Where my code is at the end. I no longer have an issue with the iostream library but when I went to compile this simple program, all that was shown at the bottom was as follows:
1>------ Build started: Project: Learning C++, Configuration: Debug Win32 ------
1>Compiling...
1>Ch1_Print1.cpp
1>Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Learning C++\Learning C++\Debug\BuildLog.htm"
1>Learning C++ - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I tried opening that file and it doesn't really show anything new...
i..........
Does anyone know what's wrong now? :cry:

What makes you think something is wrong ? It clearly indicates the build succeeded and there are 0 errors.

You program is built, you just have to run it.

Also do not use #pragma once , use a proper portable header guard

C++:
#ifdef   CH1_PRINT_H
#define  CH1_PRINT_H
......
#endif // CH1_PRINT_H
Here are (some of ) the books I used for C++:

Learning the language :
C++ Primer : by Stanley B. Lippman, Josée Lajoie
http://www.amazon.com/Primer-4th-St...=sr_1_1?ie=UTF8&s=books&qid=1247114942&sr=1-1

Learning how to use the language (Beginner) :
Effective C++ : Scott Meyers
More Effective C++ : Scott Meyers
Effective STL : Scott Meyers
C++ FAQs : Cline, Lomow & Girou http://www.amazon.com/FAQs-2nd-Mars...=sr_1_1?ie=UTF8&s=books&qid=1247115191&sr=1-1


Learning how to use the language (Intermediate) :
Exceptional C++ : Herb Sutter
More Exceptional C++ : Herb Sutter
+ anything else you can get your hands on by Sutter, the guy's a God in C++ :)


I also suggest C++ in a Nutshell as an essential reference.
 
Puttable, now that you have installed VC++, you need to learn how to use it.

From your post, I can see that you were able to compile the program. To run the program use Ctrl+F5.

BTW, Eclipse would be able to compile your program as well. You will need to read a little bit more about it. Google for Eclipse C++. If that is too much effort, click on this link.

http://tinyurl.com/nxrl4m

Thank you Alain. Your link is hilarious.
 
Thank you for both of these responses, you were very helpful.

Pleasure. Stick with it, there will be hard and frustrating times with C++ and overall I find it a joy and an artform to code.

Out of curiosity, are you an FO Quant?

Yes.

I guess FO would essentially mean Sales & Trading?

Not necessarily. There are alot of people on the floor other than just Sales & Trading. Quants, FO developers, Structurers, Analysts, Quoters etc.
 
Sorry I seem to have overlooked this post earlier on...

What makes you think something is wrong ? It clearly indicates the build succeeded and there are 0 errors.

You program is built, you just have to run it.

Also do not use #pragma once , use a proper portable header guard
I think this is just something I will have to pick up as I code more and more in C++. I initially thought that doing this would execute the program, but now it seems that it just checks for errors. And once it says there are no errors then you can do Ctrl+F5 to execute the program in command prompt.

C++:
#ifdef   CH1_PRINT_H
#define  CH1_PRINT_H
......
#endif // CH1_PRINT_H
Here are (some of ) the books I used for C++:

Learning the language :
C++ Primer : by Stanley B. Lippman, Josée Lajoie
http://www.amazon.com/Primer-4th-St...=sr_1_1?ie=UTF8&s=books&qid=1247114942&sr=1-1

Learning how to use the language (Beginner) :
Effective C++ : Scott Meyers
More Effective C++ : Scott Meyers
Effective STL : Scott Meyers
C++ FAQs : Cline, Lomow & Girou http://www.amazon.com/FAQs-2nd-Mars...=sr_1_1?ie=UTF8&s=books&qid=1247115191&sr=1-1


Learning how to use the language (Intermediate) :
Exceptional C++ : Herb Sutter
More Exceptional C++ : Herb Sutter
+ anything else you can get your hands on by Sutter, the guy's a God in C++ :)


I also suggest C++ in a Nutshell as an essential reference.

Thank you for the suggestions. These books look great though given the time constraint I think I am resigned to the book I currently have (plus http://www.amazon.com/Sams-Teach-Yourself-Minutes-2nd/dp/0672324253 as a sort of pocket reference).
 
Back
Top