Author Topic: Coding and Scripting > Learning C++  (Read 11862 times)

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #15 on: December 04, 2009, 03:21:23 PM »
Quote
That was my attempt to start teaching. It appears to have failed horribly on the start up.

I didn't view it that way. I can only count on one hand the number of programs I've ever compiled in C++. I've never before coded something from scratch in this language. By 'beef' was it seemed apparent that no one was 'checking the work'.  :o

 :)
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline Chomp

  • Full Member
  • ***
  • Posts: 173
Re: Coding and Scripting > Learning C++
« Reply #16 on: December 04, 2009, 03:28:51 PM »
Neal,

I assume you're referring to my post.  I posted that strictly for educational purposes and to give people something to chew on, maybe look up and learn a bit about it, no other purpose intended.

As for teaching I've been assuming that we will all just learn off of each other since we're all just starting out.  I know that you were elected teacher, but that seems unfair as we are all at the same point.  BTW, I thought your first attempt at an assignment was fine.  I did do it as you seen!  However, if someone like TheChief, who it's obvious has the most C++ knowledge, wanted to direct some lessons I wouldn't complain.

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #17 on: December 04, 2009, 03:34:52 PM »
@ chomp:
I used your example in test.cpp:

Code: [Select]
  ~]$ g++ test.cpp
test.cpp:7: error: stray ‘\302’ in program
test.cpp:7: error: stray ‘\240’ in program
test.cpp:7: error: stray ‘\302’ in program
test.cpp:7: error: stray ‘\240’ in program
test.cpp:7: error: stray ‘\302’ in program
test.cpp:7: error: stray ‘\240’ in program
test.cpp:8: error: stray ‘\302’ in program
test.cpp:8: error: stray ‘\240’ in program
test.cpp:8: error: stray ‘\302’ in program
test.cpp:8: error: stray ‘\240’ in program

 ???
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: Coding and Scripting > Learning C++
« Reply #18 on: December 04, 2009, 03:36:37 PM »
It wasn't you Chomp. It was that the only mention of what I had posted was that it wasn't a complete program (wasn't meant to be). All of you seem pretty much ahead of me. Sure I can put together a program, but I feel hampered by not knowing what some of it means, i.e. how to define it / its use.

In future, I'll be careful to only post complete, runnable programs, and I'll leave the teaching to those with more knowledge.


Offline Chomp

  • Full Member
  • ***
  • Posts: 173
Re: Coding and Scripting > Learning C++
« Reply #19 on: December 04, 2009, 03:40:21 PM »
@ chomp:
I used your example in test.cpp:

Code: [Select]
  ~]$ g++ test.cpp
test.cpp:7: error: stray ‘\302’ in program
test.cpp:7: error: stray ‘\240’ in program
test.cpp:7: error: stray ‘\302’ in program
test.cpp:7: error: stray ‘\240’ in program
test.cpp:7: error: stray ‘\302’ in program
test.cpp:7: error: stray ‘\240’ in program
test.cpp:8: error: stray ‘\302’ in program
test.cpp:8: error: stray ‘\240’ in program
test.cpp:8: error: stray ‘\302’ in program
test.cpp:8: error: stray ‘\240’ in program

 ???

Hmmmm, strange.  Unfortunately, I don't have enough knowledge to tell you what those compile errors mean.  But let's see if we can solve this.  Do you have gcc-c++ installed?

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #20 on: December 04, 2009, 03:43:14 PM »
It wasn't you Chomp. It was that the only mention of what I had posted was that it wasn't a complete program (wasn't meant to be). All of you seem pretty much ahead of me. Sure I can put together a program, but I feel hampered by not knowing what some of it means, i.e. how to define it / its use.

In future, I'll be careful to only post complete, runnable programs, and I'll leave the teaching to those with more knowledge.


Nar don't let dungbags like me stop ya.  ::) We managed to get the thing going. And now we have more knowledge.  ;D ;D
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #21 on: December 04, 2009, 03:43:52 PM »
@Chomp:
I guess so, cos I got the former code to work flawlessly.  ???

Edit: Confirmed. gcc-c++ is installed. Version is latest and greatest.  ;D

You cant get it to run your end?
« Last Edit: December 04, 2009, 03:46:52 PM by F.Luent »
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline Chomp

  • Full Member
  • ***
  • Posts: 173
Re: Coding and Scripting > Learning C++
« Reply #22 on: December 04, 2009, 03:57:28 PM »
@Chomp:
I guess so, cos I got the former code to work flawlessly.  ???

Edit: Confirmed. gcc-c++ is installed. Version is latest and greatest.  ;D

You cant get it to run your end?

Compiles fine on my end.  I did a little Googling and this might be your problem.  Stray characters mean illegal (encoding of) characters(the compile errors you're getting).  The problem could result from you copy/pasting this code but " might be appearing as when you paste it into your editor of choice.  Try manually replacing " and see if it compiles.

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11587
  • ----IOFLU----
Re: Coding and Scripting > Learning C++
« Reply #23 on: December 04, 2009, 04:01:18 PM »
It may seem a bit picky, but my post that F.Luent complained of not providing something to "make it go" was not about the code or compiling the code. Please re-read it. You'll see that it was about line structure.

As I said when I was nominated to teach:
Quote
"Teacher?" Me? Are you out of your ever-loving minds? I don't know enough to teach, though I do appreciate the honour. If I tried to teach the subject, we'd all be in trouble. ::)

That was my attempt to start teaching. It appears to have failed horribly on the start up. Like my previous attempt to start a discussion on the symbols (I started off with { and } and said that what is between is a block of code.), it was something that interested me.  

TheChief,
If you would do the teaching, I'd be grateful.


Neal:

Don't be so hard on yourself. We're friends here, just trying to learn a little bit and have fun in the process. Each example given will lead to questions, which shouldn't be viewed as complaints, just a place to pick up from the last lesson. Chomp pretty much showed what was needed to get the code to compile, which is just slightly different from what I did. Had he not already posted the answer for F.Luent, I would have.

You already said we shouldn't expect to have each example in a compilable format, and that's fine. If someone asks what else is needed, either you, or any one of us playing with this, can answer, if one of us figure it out. It's good practice for the students, not meant to put pressure on the teacher. As we move along, anyone can take a shot at playing teacher, if they come up with something they've figured out and think would be interesting to the rest of us.

There are bound to be bumps in the road as we go along, until we get a few lessons done, and that's to be expected. We'll get to where thing go more smoothly after we get more familiar with what is working and learn, in the process, what could be improved on. Until we get the rough spots sanded down, hang loose, my friend. ;) ;D
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #24 on: December 04, 2009, 04:08:07 PM »
@Chomp:
I guess so, cos I got the former code to work flawlessly.  ???

Edit: Confirmed. gcc-c++ is installed. Version is latest and greatest.  ;D

You cant get it to run your end?

Compiles fine on my end.  I did a little Googling and this might be your problem.  Stray characters mean illegal (encoding of) characters(the compile errors you're getting).  The problem could result from you copy/pasting this code but " might be appearing as when you paste it into your editor of choice.  Try manually replacing " and see if it compiles.

~]$ cat test.cpp
Code: [Select]
#include <iostream>

using namespace std;

int main ()
{
   cout  << "Hello World!"
   << endl;
}
??? Beats me.  :-\
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Offline Chomp

  • Full Member
  • ***
  • Posts: 173
Re: Coding and Scripting > Learning C++
« Reply #25 on: December 04, 2009, 04:22:08 PM »
@Chomp:
I guess so, cos I got the former code to work flawlessly.  ???

Edit: Confirmed. gcc-c++ is installed. Version is latest and greatest.  ;D

You cant get it to run your end?

Compiles fine on my end.  I did a little Googling and this might be your problem.  Stray characters mean illegal (encoding of) characters(the compile errors you're getting).  The problem could result from you copy/pasting this code but " might be appearing as when you paste it into your editor of choice.  Try manually replacing " and see if it compiles.

~]$ cat test.cpp
Code: [Select]
#include <iostream>

using namespace std;

int main ()
{
   cout  << "Hello World!"
   << endl;
}
??? Beats me.  :-\

I copy/pasted the code from your post and again it compiled without complaint, so beats me too.  At least we know that this results from an illegal encoding of characters, so it's a start.  Unfortunately I have to go to work and can't help you anymore, hopefully someone else will help you solve your problem before I get home tonight.

I'd also like to make an assignment if I may:

Code: [Select]
#include <iostream>

using namespace std;

int  main  ()
{
   cout  << "Hello World!";
   return  0;
}

Code: [Select]
#include <iostream>

using namespace std;

int main ()
{
   cout  << "Hello World!"
   << endl;
}

Both examples do the exact same thing.  However, in the first example there are two statements in the body of the code(in between { and }) and in the second example there is only one statement.  This is known as a ________ statement.  Fill in the blank and tell us what an ________ statement is and how it works.  Not looking for an in depth description just something to demonstrate you understand the basics of an  ________ statement.  And no looking at the other threads in Code Hackers, since the answer is contained in one of the posts in another thread.  Try to figure it out on your own.

Neal:

Don't be so hard on yourself. We're friends here, just trying to learn a little bit and have fun in the process. Each example given will lead to questions, which shouldn't be viewed as complaints, just a place to pick up from the last lesson. Chomp pretty much showed what was needed to get the code to compile, which is just slightly different from what I did. Had he not already posted the answer for F.Luent, I would have.

You already said we shouldn't expect to have each example in a compilable format, and that's fine. If someone asks what else is needed, either you, or any one of us playing with this, can answer, if one of us figure it out. It's good practice for the students, not meant to put pressure on the teacher. As we move along, anyone can take a shot at playing teacher, if they come up with something they've figured out and think would be interesting to the rest of us.

There are bound to be bumps in the road as we go along, until we get a few lessons done, and that's to be expected. We'll get to where thing go more smoothly after we get more familiar with what is working and learn, in the process, what could be improved on. Until we get the rough spots sanded down, hang loose, my friend. ;) ;D

Definitely +1


Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #26 on: December 04, 2009, 04:33:01 PM »
Quote
This is known as a ________ statement.

Gee, for a second there I thought you were swearing.  ;D
$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11587
  • ----IOFLU----
Re: Coding and Scripting > Learning C++
« Reply #27 on: December 04, 2009, 04:53:43 PM »
@Chomp:
I guess so, cos I got the former code to work flawlessly.  ???

Edit: Confirmed. gcc-c++ is installed. Version is latest and greatest.  ;D

You cant get it to run your end?

Compiles fine on my end.  I did a little Googling and this might be your problem.  Stray characters mean illegal (encoding of) characters(the compile errors you're getting).  The problem could result from you copy/pasting this code but " might be appearing as when you paste it into your editor of choice.  Try manually replacing " and see if it compiles.

~]$ cat test.cpp
Code: [Select]
#include <iostream>

using namespace std;

int main ()
{
   cout  << "Hello World!"
   << endl;
}
??? Beats me.  :-\

Don't know if it will help, but did you save the file with a new line after the code. I did a copy/paste too, ended with a new line before saving, and it compiled for me also.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline Village Idiot

  • Hero Member
  • *****
  • Posts: 2345
  • Have A Nice Day.
Re: Coding and Scripting > Learning C++
« Reply #28 on: December 04, 2009, 05:30:35 PM »
Quote
Don't know if it will help, but did you save the file with a new line after the code. I did a copy/paste too, ended with a new line before saving, and it compiled for me also.
   

Thanks OP, but yeah that was the first thing I did after Chomp mentioned the copy/paste issue. And yeah, there was no newline. -whoops- I should know better. Odd the compiler didn't mention it as it does with when ever I do anything in C. I always seem to make that mistake somewhere along the way.

But it didn't fix it..Same result.


$ fortune
No Microsoft products were used in any way for the creation of this message.
If you are using a Microsoft product to view it, BEWARE! - I'm not
responsible for any harm you might encounter as a result.

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11587
  • ----IOFLU----
Re: Coding and Scripting > Learning C++
« Reply #29 on: December 04, 2009, 05:43:29 PM »
Quote
Don't know if it will help, but did you save the file with a new line after the code. I did a copy/paste too, ended with a new line before saving, and it compiled for me also.
   

Thanks OP, but yeah that was the first thing I did after Chomp mentioned the copy/paste issue. And yeah, there was no newline. -whoops- I should know better. Odd the compiler didn't mention it as it does with when ever I do anything in C. I always seem to make that mistake somewhere along the way.

But it didn't fix it..Same result.


What editor did you use?
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...