## Home

Update 11/14/11: Starting 11/15/11 (Tuesday, tomorrow) I am going to be starting from the beginning and redoing every single lesson. Each lesson is going to have exactly 3 parts, each of which will have a video.

Videos will be broken up as follows:
1. Logic
2. Lesson
3. Homework

The contents of each will be as follows:

Logic: This is where I will present a problem and explain the need for a better solution than what we’re working with. I’ll explain the logic of how we attack the problem in the most simple logic, and then in the most efficient forms (if different). This section will tend to be language agnostic, and will focus on design paradigms that will help you learn.

Lesson: This will be the “meat and potatoes” of the course, it will be taking the logic from the logic section and implement it in code. This is going to be done in C++ ONLY. There will be a lot of C-style problem solving logic before I present the “proper” C++ solution. The reasoning behind this is to show you how to solve a problem with logic, rather than a premade function that handles it for you. Until we hit the yet-to-be-announced “intermediate C++” section we’re going to be solving problems long-form.

Homework: The homework section is going to be just that, homework. I’ll take a minute or two to assign you a homework that will test your understanding of the concepts covered, I’ll be commenting on style, logic, and overall flow of the program.

1. Aaron W says:

I know i’m joining the class a little late but, after watching the 9th (I think) tutorial and heard you challenge students to make a calculator I tried it out. I tried doing this without any reference all by myself. Despite being super awkward I’m just happy it works. I wasn’t able to include the exponent part but whatever.

http://ideone.com/a3yvw

What do you think I could have done to make this less awkward?

• Damien says:

At the point you’re at in learning right now, this is absolutely where you should be, don’t worry about making the numeric input any less awkward, that’ll come with time and practice and learning more constructs of C++.

• Damien says:

In general things being “less awkward” isn’t a priority at this phase. When you continue and get much further into the series we’ll start getting into how to do things like this in a more sensible manner, probably somewhere after the big case study that I’m doing now I’ll get into using string / stringstream / loops to enter something less awkward like 548 * 127 then hitting enter to get the result. But for now I wouldn’t mind too much about it feeling ‘unnatural’.

• Matt L says:

Like this

http://ideone.com/sm579

I just started watching your lectures too. I have some experience and I need to freshen up on C++ and your lectures are great for that.

• Damien says:

I’m glad that you’re enjoying them so far =), if you need anymore help, please feel free to ask, as I’m more than happy to help.

2. yesimnathan says:

I’m glad to see that you’re still around Damien! I noticed that nothing’s been thrown on reddit recently. Keep up the great work.

Yeah, I’ve been quiet lately. Lots in my personal life and lots of behind the scenes stuff to get the site up and running, so I’m hoping that I’ll be more effective here than I was on the old forums. Goodness knows I can sort / produce content in a more meaningful fashion.

3. Donna says:

Hi, Damien!

I found you (and your comment below) on another website which led me to cppforbeginners which led me here to find you! It appears I’m reading the same book as the poster below and am in the same stage as him/her and am having the same problem. I also saved a source file Motto.cpp in Word Pad, and I’m using Windows, too. I enter:

g++ Motto.cpp -o Motto.exe

and I get:

g++: Motto.cpp: No such file or directory
g++: no input files

I tried this syntax you suggested:

g++ -g .\Motto.cpp -o Motto -lm

and I get the same response, only without the second line:

g++: .\Motto.cpp: No such file or directory

The book came with a cd with codeblocks for Windows, and I added the MinGW’s location to the Path variable. Do you have any other ideas as to why the g++ compiler is not finding the source file Motto.cpp? Just in case the code makes a difference, here’s the very simple source code:

#include

int main()
{
std::cout << "Solidum petit in profundis!|n";
return 0;
}

Thank you very much!

C++ compiler not working?

I'm just now starting to learn C++ programming and on the basic task of making the first program. However, I'm stuck on it and I can't find my way out. I've added the compiler to all files, and have saved the code text in WordPad, saved as .cpp file but it doesn't recognize the files existence. I've even downloaded the file from the website (from the book I'm reading) and it didn't help either.
I'm all turned around and have no idea what to do.
1 month ago
Report Abuse

I use the GCC compiler by the way

1 month ago

g++ Motto.cpp – o Motto.exe
g++: Motto.cpp: No such file or directory
g++: o: No such file or directory
g++: Motto.exe: No such file or directory
g++: -E or -x required when input is from standard input

1 month ago
.

Damien Bell

Best Answer – Chosen by Voters

All these answers are surprisingly crappy. Not really too surprised about that.

In order to compile using G++ in windows, you should be using a much different syntax than the syntax that you'd be using in a linux / unix environment.

Example:
g++ -g .\Motto.cpp -o Motto -lm

Also, did you add the program path? Did you escape that properly for use with windows? You should consider getting a more modern IDE / more versatile compiler solution that works with windows. Visual C++ Express / netbeans running with cygwin / g++ / make /gdb running on an external terminal is pretty beautiful as well.

Source(s):

Host of CppForBeginners.com/ programmer.
1 month ago
Report Abuse

• Damien says:

Hello Donna and welcome aboard, I’m glad that you found your way here, I’ve been busy making this website since I answered your question, it’s been tough, but hell, I like it.

Now, I’m noticing that you’re using G++ as your compiler, are you opposed to using an IDE to interface with your compiler, as I presently have instructions for setting up / running netbeans.

As far as G++ goes, I would need to know a lot more about your system to guide you through this, which OS, which version of that OS, which version of G++? You can also look into running Cygwin with G++ (watch video #0) and using cygwin / G++ to compile things directly. If you need any more help on the specifics, please post here again.

• Damien says:

As an aside, if you want to use code, use the ` <code>` tag and type “</code>” When you want to stop typing using code formatting.

I believe you missed `<iostream>` but that may have just been the abovementioned formatting.

4. Raiselito says:

Hey Damien, I’m having trouble with this code…When I divide 2/5 I get zero, and My Addition section for the calculator is lacking “style” compared to the other operations but it contains the same code.

I’d like some help
Here’s the code
[code]
#include
#include
#include

using namespace std;

int main ()

{double a=0,b=0,choice;
char exit=' ';

while(exit != 'n'){ //WHILE LOOP
cout << "\n\n\n\n\n" <<" Raisel's Calculator!\n\n"<<"\nPick an option:\n\n\n "<<"\n Select 1 to Add" << endl;
cout << "\n Select 2 to Subtract" << endl << "\n Select 3 to Multiply" << endl;
cout << "\n Select 4 to Divide" << endl << "\n Select 5 to Square Root\n\n\n" << endl<< endl;
cout <> choice;

cout << setiosflags(ios::showpoint) << setprecision (1);

switch(choice){

case 1:{ cout << "\n\n\nWhat two numbers would you like to add? "; //ADDITION FUNCTION
cout <>a;
cout <>b;
cout << "\n";
cout <<a<<" + "<<b<< " = "<<a+b <<endl;
cout <> exit;

break;
}
case 2:{ cout << "\n\n\nWhat two numbers would you like to subtract? ";
cout <>a;
cout <>b;
cout << "\n";
cout <<a<<" - "<<b<< " = "<<a-b <<endl;
cout <> exit;

break;
}
case 3:{ cout << "\n\n\nWhat two numbers would you like to multiply? "; //MULTIPLICATION FUNCTION
cout <>a;
cout <>b;
cout << "\n";
cout <<a<<" * "<<b<< " = "<<a*b <<endl;
cout <> exit;

break;
}
case 4:{ cout << "\n\n\nWhat two numbers would you like to divide? "; //DIVISION FUNCTION
cout <>a;
cout <>b;
cout << "\n";
cout <<a<<" / "<<b<< " = "<< a/b <<endl;
cout <> exit;

break;
}
case 5:{ cout << "\n\n\nWhat number would you like to squareroot? "; //SQUAREROOT FUNCTION
cout <>a;
cout << "\n";
cout << "\nThe squareroot of "<<a<<" is "<< sqrt(a) << endl;
cout <> exit;

break;
}
default:{break;} //DEFAULT
{
cout <> exit;

if(exit == 'n'){break;}
}
}
}
return 0;
}

[/code]

5. Gordnfreeman says:

Wow guess I arrived a little late haha I am still going to go and work through the videos, thank you for doing this.

6. Lucas Simon says:

Are you going to include any lectures on inline assembly programs within C++? Also are you going to include lectures on multithreading?

• Damien says:

I’m not too sure about the destiny for C++ overall, I do have a plan on including multithreading (amongst other stuff) for java, and I’m sure that the OOP concepts are very similar to a project that I did a while back in C++, but it was hacky, so I’ll need to research the ‘proper’ way to do it before then.