More help

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
. turns out the error is actually in my webcount.h file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

	

#ifndef WEBCOUNTER_H
#define WEBCOUNTER_H
#include <iostream>
using namespace std;


class  name {
    public:
           void display(); 
           void set(int n);
           void hit();
           void reset();
           int get();

         private:
           int counter;

};
}

#endif 



Exact message is "webcount.h:19:1 error: expected declaration before '}' token" 
I messed up the code line up top. Am I supposed to delete the curly bracer in line 19? Because it just creates even more issues.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef WEBCOUNTER_H
#define WEBCOUNTER_H
#include <iostream>
using namespace std;


class  name {
    public:
           void display(); 
           void set(int n);
           void hit();
           void reset();
           int get();

         private:
           int counter;

};
}

#endif  
The indentation makes this error pretty obvious.

You have an extra } on line 45
Okay but I delete it and i just get even more errors.
Now that I did that I am getting the error ".text+0x18): undefined reference to 'main'
collect2: error: ldd returned 1 exit status" whenever I try to compile my WebCounter.cpp using the g++ command.
http://www.cplusplus.com/forum/beginner/112416/

Okay but I delete it and i just get even more errors.

Please post these new errors.
In your source code, I assume you have this:

1
2
#include "someHeader.h"
#include "WebCounter.h" 


So you probably have a problem in "someHeader.h", then you put a } in WebCounter.h to get rid of a few errors, but it was corrected in the wrong place.
Last edited on
Also delete lines 3 and 4 in your code - they aren't necessary for that file.

Line 4 isn't necessary in any case - it can lead to naming conflicts. Just put std:: before each std thing - std::cout, std::cin, std::endl, std::string, std::vector etc. There are lots of things in the STL and it is documented in the reference section at the top left of this page.

Danny Toledo is right, if you have errors then post them in full, and the code they refer to.

EDIT:

This post is about the same topic as your other one. Could I ask you to please not do that? The trouble is that people make an effort to reply, and might make quite a long post, only to discover that the exact same things were talked about in the other post, which makes their effort seem to be a waste of time.

So, could you decide which post you want to continue with, then in your other post direct everyone to reply to the one you want to use.
Last edited on
Topic archived. No new replies allowed.