help me guys

im so confused why this one didnt work
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
#include <conio.h>
#include <iostream>

using namespace std;

class angka
{
      public :
      int a;
      
      angka(int a)
      {
                cout<<"input yang anda masukan adalah"<<a;
      }
      ~angka()
      {
             cout<<endl<<"destruct jalan";
      }
};
int main(){
    int x;
    cout<<"input 1 angka ";
    cin>>x;
    angka( int x);//this one didnt work
    getch();
    return 0;
}
angka(x); // This one works
Hello gwpalingjago14,

It hit me lat night just as the computer shut down. SakurasouBusters suggestion although correct in removing the int makes no difference because you are calling the constructor and that is not allowed.

what you can do is after line 23 add angke test(x); this way when you create an instance of class angka the constructor will be call passing x to the constructor.

Hope this helps,

Andy
Topic archived. No new replies allowed.