Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8707927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:59:12+00:00 2026-06-13T03:59:12+00:00

I am using this pretty simple class without using any inheritance. class A {

  • 0

I am using this pretty simple class without using any inheritance.

class A
{
  int a;
  int b;

public:
 A(int x, int y) { a = x; b = y;}
 A() :A(0,0){};
 ~A(){};
} ;

int main ()
{
  A a1, a2(5, 7) ;
}

I get this error.

error C2614: ‘A’ : illegal member initialization: ‘A’ is not a base or member

There are similar questions on SO but they relate to inheritance. Can someone explain the reason and what does standard say about that?

EDIT:

It would be better if someone elaborate more on the forwarding constructor and this feature in C++11.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:59:13+00:00Added an answer on June 13, 2026 at 3:59 am

    If you can use C++11, you could initialize A() from A(int, int). This is not possible in C++03, where you have to write two separate constructors.

    If you want your code to work in C++03, you have two options:

    • Create a function init(int, int) and call it from each of your constructors. This is a good choice if your constructor does a lot of work.
    • Duplicate behaviour in both constructors. This is a good choice when all you are doing are member initializations.

    You can also call a base constructor from a child class constructor. For instance, if you have

    class A {
        A(int, int);
    };
    class B : public A {
        B(int, int);
    };
    

    You could write

    B::B(int x, int y) : A(x,y) {}
    

    This is what your compiler means when it says that A is not a base, it is expecting this situation.

    All of these are compatible with C++03.

    You could also upgrade your compiler to support C++11 features. I wouldn’t recommend this if you are working in Linux and want your project to compile in Windows because Windows compilers don’t implement all the C++ features that Linux compilers do (unless you pay for a good compiler).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is pretty simple: I'm using NetBeans on Linux with Android emulator 1.6. I
Im pretty sure this has a simple solution. I am using jCarousellite, and i
Using this xslt file found on this blog to pretty print xml using Nokogiri,
Currently, I am using this query, which does a pretty good job of finding
This is pretty much a duplicate question but instead of using Castle Dynamic Proxy
I'm using sqlite3 and this would be pretty easy if it supported TOP syntax
I'm using the CurrentUICulture for Localization. This works pretty well until the UI Culture
I would like to create this shape using just css. I am pretty sure
This is my first app using storyboards/segues, and I'm pretty sure the answer to
Consider this simple class that demonstrates RAII in C++ (From the top of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.