Comp. Language help

Just out of curiousity, what is the site for learning C++ that you used? All I know is basic iostream.h things and some basic math functions, and I've been wanting to learn.
 
Myles (Zealot) and I are good friends. We use to go to school together and will next year actually. Anyhow last year at school one day we found this site that teaches you c++ and I think its what your looking for: Click Here

Tell me if that helps.
 
I can't get any of the compilers to work. I'd like to have one that I can just use on the command line. Although nothing seems to be installing right. Borland=$$. MSVC++=Junk. DEVC++=pile of stink.
 
get g++

it's a nice compiler, but also ensure that you are using the command line correctly there are certain commands teh compiler needs to understand what you are trying to do
 
Is there a g++ for windoze? Right now I'm on redhat9 and I'm flying through my C++ book, taking lots of stuff in. Anyway, I didn't look back at this thread till just now, and I came across g++ before looking here, it works great. I tried gcc and it doesn't work for me. I've written 3 programs tonight and they've all compiled perfectly, including the "Hello World!" which was my bain for so long. Long live linux.
 
yes there is a g++ for windows, an u can get free ide's to make compile and programming easier for it (jgrasp and devshed are two)

You might also want to try programming in Java and C#.

Java has really nice GUI elements (in the javax classes)
 
I like programming in Linux though...especially with the fluxbox interface, it makes everything look so professional. I guess I'll learn on linux and then maybe move over to windows, so I can learn how to create the GUI elements for it. I'm up to learning the standard library now, having completed a lot of the iostream stuff. I must be a geek/nerd, this is fun to me.
 
Anyone mind taking a look at this and seeing what is wrong...g++ won't compile it.
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
#include <iostream>
using namespace std;
void func1();
void func2();

int count;

int main()
{
int i;
for(i=0; i<10; i++) {
count = i * 2;
func1()
}
return 0;
}

void func1()
{
cout << "count: " << count;;
cout << '\n';
func2()
}
void func2()
{
int count;

for(count=0; count<3; count++) cout << '.';
}
[/QUOTE]
Debugger information
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
glovar.cpp: In function `int main()':
glovar.cpp:13: use of `count' is ambiguous
glovar.cpp:7: first declared as `int count' here
/usr/include/c++/3.2.2/bits/stl_algo.h:390: also declared as `
std::iterator_traits<_Iterator>::difference_type std::count(_InputIter,
_InputIter, const _Tp&amp;)' here
glovar.cpp: In function `void func1()':
glovar.cpp:22: use of `count' is ambiguous
glovar.cpp:7: first declared as `int count' here
/usr/include/c++/3.2.2/bits/stl_algo.h:390: also declared as `
std::iterator_traits<_Iterator>::difference_type std::count(_InputIter,
_InputIter, const _Tp&amp;)' here
glovar.cpp:25: parse error before `}' token
[/QUOTE]

The only thing wrong with my book is it isn't a live person and can't look at my code to debug it.
 
Is there a way to initialize all the elements of an array to a certain value other than making a for loop that goes through all of them?

I have an array that I declare as such:
bool *numberlist = new bool[iLimit];

where iLimit is an integer entered by the user

I want to initialize all the values to TRUE, but is there a simpler way to do it other than make a for look that goes through every element and assigns them as TRUE?
 
sorry, C++

didn't mention it because pretty much everything in this thread's about C++
 
In reply to your code that wouldn't compile a page before.
I do Java instead of C++ but I might be able to help.
The changes I'll do are in red.
[b said:
Quote[/b] ]
#include &lt;iostream&gt;
using namespace std;
void func1();
void func2();

int count <span style='color:red'>= 0; //initializing count</span>

int main()
{
  int i;
  for(i=0; i&lt;10; i++) {
      count = i * 2;
      func1()
  }
  return 0;
}

void func1()
{
  cout &lt;&lt; "count: " &lt;&lt; count;;
  cout &lt;&lt; '\n';
  func2()
}
void func2()
{
  int count; <span style='color:red'>//Wrong, 'count' exists
                                     //as a class variable</span>      

  for(count=0; count&lt;3; count++) cout &lt;&lt; '.';
}
Ok, I think your problem is just having to initialize the variable 'count' before using it in all your code.  You must do this because it is a class variable.

Ooh! I see another problem your lucky I caught it.
wow.gif

Your second problem is making a new count, why make a new one if you already have one?
 
kralgon, i've always walked through a array to init it in C++

What exactly are you trying to do?

Is this array, basically assigning false to certain values associated with another array?

if so, it would probably be better to use a linked list, of items that are false, and assume if they're not in the LL that the item is true.

*pardon the code, it's been awhile for this, but you'll get the idea*
[b said:
Quote[/b] ]
class Node {
bool Value;
int ItemID
Node NextNode;
};

class LinkList {
node *HeadPtr

void add(bool value, int ItemId) {}
bool search (int FindID) {}
...
}


int main {
linklist ll

if UserArray[x].bool == false
{
  ll.add(false, x)
}

}

does that make sense?

the other post..




[b said:
Quote[/b] ]#include &lt;iostream&gt;
using namespace std;
void func1();
void func2();
It's not necessary to init the value here, becase this is not Java, and C++ doesn't care until u use it
int count = 0; //initializing count

int main()
{
 int i;
 for(i=0; i&lt;10; i++) {
     count = i * 2;
     func1()
 }
 return 0;
}

void func1()
{
 cout &lt;&lt; "count: " &lt;&lt; count;;  two semicolons will throw an error
 cout &lt;&lt; '\n';
 func2()
}
void func2()
{
 int count; //Wrong, 'count' exists
                                    //as a class variable  
Yes an no.  It's wrong because you're mishandling scope, but the compiler should accept it, and it should print out 3 periods    Also you need to find out whether to use the single quote or double quote.  You've been switching back and forth

 for(count=0; count&lt;3; count++) cout &lt;&lt; '.';
}
 
I was making a simple algorithm to output all the primes from 1 to the input number. If the array element associated with the number is false, it is not prime, and if it's true, the prime is outputted, and all multiple of the primes are set to false. So at the beginning, I want all the numbers to be set to true. I guess looping through it is the best way then?
 
What I was trying to do there is initalize a global and a local variable with the same name. I would probably never have to do something like that in real code cuz thats just plain dumb, but it's still a pain in the butt nonetheless, because my book says it should work, but it doesn't.
 
pasa-- that is working. what's wrong is that you're not telling it that the first int count (on line 7) is a global variable. The system doesn't automatically know that
 
It's been a month now and I have a basic understanding of how C++ works, now I want to expand to other things. I remember Kralgon wrote a battle net bot...I'd like to do something similar except as an IRC bot. I found a header file called cpIRC, but I'm not sure how to use all of the things in it because the documentation is a bit over my head. If someone thinks they can write a simple C++ IRC bot that connects to irc.gamesnet.net and prints out everything it receives in a command line window be my guest. I'd like to have some source with my manuals.
 
Back
Top