
-----------------------------------
[Gandalf]
Sun Jun 26, 2005 4:30 pm

A Start on C++ Some First Programs/Questions
-----------------------------------
Well, I have decided that my lofty goal for the summer is to learn C/C++ and VB.NET.  Well, I'm hoping to get at least a basic knowledge of one of them, so I'm starting with C++ (I've already tried C).  I will post some of the programs I make and questions I have over here till I give up (which will hopefully not happen).  If I can't do C++ then I'll fall back to C, and if not that then I'll fall back to either VB.NET or Ruby.

Well, alright, I think I have an alright understanding of cout and cin, and now I'm going into classes and objects.  Then I will go to constructors/deconstructors, multiple objects of the same class, private members and friend functions, inheritance, virtual funtions, and pure virtual functions, then file objects and by then we'll see...  If there are any tutorials you suggest on this site or on the internet then please suggest them since I need all the help I can get!

I was looking at inline assembly, and heck - it doesn't seem too hard.  Once you get past that barrier then inline machine code doesn't seem all that bad either.  But then again, that's just me and my insane first impressions.

Ok, I'll post some of my code when I reinstall my editor/compiler, but first I have a simple newb question.

Can you declare the value of a variable inside a class in C++?  I see how it's not neccessary, but I'm just not sure if its possible.

Oh, and if you know of any good reference guides to C/C++ then I would be really happy too :P .

*EDIT*  Oh, and is it wise to use some C libraries while coding in C++?  Or should you just use pure C++?  Are some C libraries also considered C++ ones?


*NOTE TO SELF*
g++ name.cpp -o name.exe
gcc name.c -o name.exe
gcj name.java -o name.exe?

-----------------------------------
Cinjection
Sun Jun 26, 2005 4:40 pm

Re: A Start on C++ Some First Programs/Questions
-----------------------------------
"]
Can you declare the value of a variable inside a class in C++?  I see how it's not neccessary, but I'm just not sure if its possible.

no, but that's what constructers are for.
"]
Oh, and if you know of any good reference guides to C/C++ then I would be really happy too :P .

www.cprogramming.com
"]
*EDIT*  Oh, and is it wise to use some C libraries while coding in C++?  Or should you just use pure C++?  Are some C libraries also considered C++ ones?  

You can, but you can turn C libs into C++ libs by adding a c infornt and getting rid of the .h. So 

#include  //c style
//becomes
#include  //c++ style

That won't always work but in most cases it will. Need more help , just ask.

-----------------------------------
[Gandalf]
Sun Jun 26, 2005 4:58 pm


-----------------------------------
Thanks.
What compiler/editor should I use? :oops: 

I had a good one for C, but it doesn't work with C++.  Do you know of a good, easy to use editor with a built in compiler?   Free, might I add.

*EDIT* Oh man, I forgot so much, even about C.  I took a basic "hello world" program just to test my C and it doesn't show hello world when compiled :?.
include 

int main()
{
   puts("Hello world");
   return 0;
}

It just says return code, execution time, and location of program.

-----------------------------------
1of42
Sun Jun 26, 2005 5:18 pm


-----------------------------------
[url=http://www.bloodshed.net/devcpp.html]http://www.bloodshed.net/devcpp.html

Dev-C++ is a great IDE.

-----------------------------------
Cinjection
Sun Jun 26, 2005 5:19 pm


-----------------------------------
I use MVC++. But you have to pay to get that one. If you want a good free compiler you can use Dev C++(googleafy)( value;
    cout  name;
std::cout  x1;
    cout > y1;
    cout > x2;
    cout > y2; 

	rise = y2 - y1;
	run = x2 - x1;

	cout name;
    std::cout  x1;
    std::cout > y1;
    std::cout > x2;
    std::cout > y2;
    double slope(static_cast(y2 - y1) / (x2 - x1));
    std::cout  name;
    std::cout  x1;
    std::cout > y1;
    std::cout > x2;
    std::cout > y2;
    double slope(static_cast(y2 - y1) / (x2 - x1));
    std::cout  Int ->a -> [a] -> Maybe Int
indexOfValueInList _ _ [] = Nothing
indexOfValueInList n val (x:xs)
  | val == x = Just n
  | otherwise = indexOfValueInList (n + 1) val xs
