No appropriate default constructor available

J. Grohmann

I'm trying to use a constructor for a 'Control' class that takes no parameters but when I try to create an instance of it I get an error saying "No appropriate default constructor available"

Here is my header:

class Control
{
public:
    Control();

private:
    Layout activeLayout;

    void createLayout();
    void moveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight,           std::string windowTitle);
    void mainLoop();
};

#endif

My cpp file:

 Control::Control()
{
    Detector mainDetector();

    createLayout();
    mainLoop();
}

and where I try to call the instructor:

int _tmain(int argc, _TCHAR* argv[])
{
    Control mainControl();

    system("PAUSE");

    return 0;
};
6502

Pay attention that

Detector mainDetector();

is a function declaration, not the definition of a variable of type Control. When there are no parameters the syntax is

Detector mainDetector;

There are cases in which the declaration of a local function is inferred even when it wouldn't seem possible... it's known as the "the most vexing parse" rule of C++.

A simple example is:

double pi = 3.141592654;
int int_pi(int(pi));

amazingly enough here int_pi is declared to be a function!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

No appropriate default constructor available on struct

From Dev

no appropriate default constructor available initialising ostream pointer

From Dev

C++ - No appropriate default constructor available

From Dev

no appropriate default constructor available error with initializer list

From Dev

ARRAY[T, SIZE] Appropriate Default Constructor Available

From Dev

Layer trees, No appropriate default constructor available

From Dev

error C2512: no appropriate default constructor available (not classes)

From Dev

C++ Error C2512: no appropriate default constructor available

From Dev

Qt4 / C++ / CMake - no appropriate default constructor available

From Dev

C++ templated class "no appropriate default constructor available"

From Dev

"No appropriate constructor available"

From Dev

Error C2512: no appropriate default constructor available - Why if properties are being initialized in constructor?

From Dev

c++ newbie error C2512: no appropriate default constructor available

From Dev

no appropriate default contractor available compiler error

From Dev

Why there's no default constructor available for struct?

From Dev

There is no default constructor available in com.marlonjones.nimbus.WeatherWatchFaceService.WeatherWatchFaceEngine

From Dev

There is no default constructor available in com.marlonjones.nimbus.WeatherWatchFaceService.WeatherWatchFaceEngine

From Dev

QuerySyntaxException locating appropriate constructor in Hibernate

From Dev

How to extend Volley Response (to fix There is no default constructor available in 'com.android.volley.Response')

From Dev

Getting error Could not locate appropriate constructor on class

From Dev

hibernate: Unable to locate appropriate constructor on class - HQL

From Dev

Criteria API Unable to locate appropriate constructor on class

From Dev

JPA - Unable to locate appropriate constructor on class

From Dev

When is a constructor called a default constructor?

From Dev

Copy Constructor with Default Constructor in Java

From Dev

Selecting the appropriate row -- Or get default one

From Dev

Default Gateway not available wireless

From Dev

No default constructor error when there is a default constructor

From Dev

Why default argument constructor is called as default constructor

Related Related

  1. 1

    No appropriate default constructor available on struct

  2. 2

    no appropriate default constructor available initialising ostream pointer

  3. 3

    C++ - No appropriate default constructor available

  4. 4

    no appropriate default constructor available error with initializer list

  5. 5

    ARRAY[T, SIZE] Appropriate Default Constructor Available

  6. 6

    Layer trees, No appropriate default constructor available

  7. 7

    error C2512: no appropriate default constructor available (not classes)

  8. 8

    C++ Error C2512: no appropriate default constructor available

  9. 9

    Qt4 / C++ / CMake - no appropriate default constructor available

  10. 10

    C++ templated class "no appropriate default constructor available"

  11. 11

    "No appropriate constructor available"

  12. 12

    Error C2512: no appropriate default constructor available - Why if properties are being initialized in constructor?

  13. 13

    c++ newbie error C2512: no appropriate default constructor available

  14. 14

    no appropriate default contractor available compiler error

  15. 15

    Why there's no default constructor available for struct?

  16. 16

    There is no default constructor available in com.marlonjones.nimbus.WeatherWatchFaceService.WeatherWatchFaceEngine

  17. 17

    There is no default constructor available in com.marlonjones.nimbus.WeatherWatchFaceService.WeatherWatchFaceEngine

  18. 18

    QuerySyntaxException locating appropriate constructor in Hibernate

  19. 19

    How to extend Volley Response (to fix There is no default constructor available in 'com.android.volley.Response')

  20. 20

    Getting error Could not locate appropriate constructor on class

  21. 21

    hibernate: Unable to locate appropriate constructor on class - HQL

  22. 22

    Criteria API Unable to locate appropriate constructor on class

  23. 23

    JPA - Unable to locate appropriate constructor on class

  24. 24

    When is a constructor called a default constructor?

  25. 25

    Copy Constructor with Default Constructor in Java

  26. 26

    Selecting the appropriate row -- Or get default one

  27. 27

    Default Gateway not available wireless

  28. 28

    No default constructor error when there is a default constructor

  29. 29

    Why default argument constructor is called as default constructor

HotTag

Archive