About with func.

Hi,

I want to a hex variable with c++.

My codes:
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
#include <iostream>
#include <cstring>
#include <stdlib.h>

using namespace std;
public class heks{
heks(){
int a,b;
cin>>a;
cin>>b;
cout<<hex<<a<<b<<"\t";
}}

main(){
char *z;
heks hex=new heks(k,l);
hex k,l;
cout<<"Would u want to make enter?:";
cin>>k;
cin>>l;
if(((cin>>k)||(cin>>l))==z)
cout<<hex<<k<<l;
else
cout<<hex<<k<<l;

system("PAUSE");
return 0;
}


When i build these code,take this take this error message:

error:expected unqualified-id before 'public'

What must i do yourself?Thanks all ur help right now.

Note:My ide is Code blocks.
Last edited on
Read this:

http://www.cplusplus.com/doc/tutorial/classes/

The public goes inside the class.

There are many other things wrong here: off the top of my head...

Missing semi-colon at end of class declaration.
You are trying to define your class functions inside the class declaration.
A char* called z is made and used, but never set to anything.
You are trying to use two variable, k and l, before creating them.
You are trying to create a heks variable with a constructor function that takes to variables, but no such constructor exists.
You are trying to create an object of type hex, but no such type exists.
Getting the user to enter values to assign to k and l makes no sense, as you've not defined the type hex so there's no way for the compiler to know how to assign these values.

There is more, but these were the first I saw.
Last edited on
Thanks Moschops.
Topic archived. No new replies allowed.