Pure virtual function with implementation fails in XCode

nikitablack

I have some pure virtual function in a class, that is defined in header file, like this:

virtual string GetStdString() = 0
{
    // some code
}

On windows it works fine, but compiling with XCode I have an error

"Expected ';' at end of declaration list"

that points to the end of line with function name.

Angew is no longer proud of SO

Whatever compiler you're using on Windows is wrong on this. That code should not compile. You can provide a body for a pure virtual function, but you cannot do so in the same declaration (pretty much only because the standard says so). Change your code like this:

class TheClass
{
  virtual string GetStdString() = 0;
};

inline string TheClass::GetStdString()
{
  // some code
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Is it valid to override virtual function with pure specifier?

From Dev

Deriving implementation of pure virtual function

From Dev

Pure virtual function overridding virtual function

From Dev

How to implement pure virtual function

From Dev

Why a pure virtual destructor needs an implementation

From Dev

Overriding a pure virtual function from templated classes

From Dev

Pure virtual and override function (c++)

From Dev

"Overloading" pure virtual function with different set of arguments

From Dev

const qualifier disappears from pure virtual function

From Dev

Is a pure virtual function actually selected in overload resolution?

From Dev

Purpose of private pure virtual function?

From Dev

Pure virtual function call interesting cases

From Dev

calling a pure virtual function from operator<<

From Dev

In C++ Is there a way for the Child to reuse the the Parent class implementation of the pure virtual function defined in GrandParent

From Dev

Return std::unique_ptr<T> from factory function creating fully hidden implementation of pure virtual interface

From Dev

Can I override a virtual function with a pure virtual one?

From Dev

How to track down "libc++abi.dylib: Pure virtual function called!" in Xcode

From Dev

Pure virtual function implementation

From Dev

Is there a pure virtual function in the C++ Standard Library?

From Dev

Is it valid to override virtual function with pure specifier?

From Dev

Pure virtual function overridding virtual function

From Dev

Why a pure virtual destructor needs an implementation

From Dev

"Overloading" pure virtual function with different set of arguments

From Dev

dllexport pure virtual class with private implementation not working?

From Dev

calling a pure virtual function from operator<<

From Dev

Wrapping the pure virtual function using Boost::Python

From Dev

Class with implementation of pure virtual function

From Dev

Default behaviour implemented to pure virtual function

From Dev

can a pure virtual function has parameters?

Related Related

  1. 1

    Is it valid to override virtual function with pure specifier?

  2. 2

    Deriving implementation of pure virtual function

  3. 3

    Pure virtual function overridding virtual function

  4. 4

    How to implement pure virtual function

  5. 5

    Why a pure virtual destructor needs an implementation

  6. 6

    Overriding a pure virtual function from templated classes

  7. 7

    Pure virtual and override function (c++)

  8. 8

    "Overloading" pure virtual function with different set of arguments

  9. 9

    const qualifier disappears from pure virtual function

  10. 10

    Is a pure virtual function actually selected in overload resolution?

  11. 11

    Purpose of private pure virtual function?

  12. 12

    Pure virtual function call interesting cases

  13. 13

    calling a pure virtual function from operator<<

  14. 14

    In C++ Is there a way for the Child to reuse the the Parent class implementation of the pure virtual function defined in GrandParent

  15. 15

    Return std::unique_ptr<T> from factory function creating fully hidden implementation of pure virtual interface

  16. 16

    Can I override a virtual function with a pure virtual one?

  17. 17

    How to track down "libc++abi.dylib: Pure virtual function called!" in Xcode

  18. 18

    Pure virtual function implementation

  19. 19

    Is there a pure virtual function in the C++ Standard Library?

  20. 20

    Is it valid to override virtual function with pure specifier?

  21. 21

    Pure virtual function overridding virtual function

  22. 22

    Why a pure virtual destructor needs an implementation

  23. 23

    "Overloading" pure virtual function with different set of arguments

  24. 24

    dllexport pure virtual class with private implementation not working?

  25. 25

    calling a pure virtual function from operator<<

  26. 26

    Wrapping the pure virtual function using Boost::Python

  27. 27

    Class with implementation of pure virtual function

  28. 28

    Default behaviour implemented to pure virtual function

  29. 29

    can a pure virtual function has parameters?

HotTag

Archive