-1

I want to ask this question... Why we can't use Camera c1(20); ???

This is making class. But we find the error in Camera c1(20);

Please let me know...

#include <iostream>

class Camera{
private:
public:
    Camera(){

    }
    Camera(int x){

    }
};

class Phone{
private:
    Camera c1(20);
public:

};

int main(){

}
user8282818
  • 111
  • 2
  • 9

1 Answers1

0

To avoid parsing issue in general (See most vexing parse),

You may use Camera c1{20}; or Camera c1 = Camera(20);

Jarod42
  • 203,559
  • 14
  • 181
  • 302