K
Kralgon
Guest
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.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
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.[b said:Quote[/b] ]
#include <iostream>
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<10; i++) {
count = i * 2;
func1()
}
return 0;
}
void func1()
{
cout << "count: " << count;;
cout << '\n';
func2()
}
void func2()
{
int count; <span style='color:red'>//Wrong, 'count' exists
//as a class variable</span>
for(count=0; count<3; count++) cout << '.';
}
[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)
}
}
[b said:Quote[/b] ]#include <iostream>
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<10; i++) {
count = i * 2;
func1()
}
return 0;
}
void func1()
{
cout << "count: " << count;; two semicolons will throw an error
cout << '\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<3; count++) cout << '.';
}