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 8675939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:04:20+00:00 2026-06-12T20:04:20+00:00

Example: H class MyClass { int x,y,z; public: MyClass(int,int,int); void X(); void Y(); void

  • 0

Example:

H

class MyClass {
    int x,y,z;
public:
    MyClass(int,int,int);
    void X();
    void Y();
    void Z();
};

CPP

class MyClass {
    int x,y,z;
public:
    MyClass(int x,int y,int z) {
        this->x=x;
        this->y=y;
        this->z=z;
    }
    void X() {
        printf("x = %d;\n",x);
    }
    void Y() {
        printf("y = %d;\n",y);
    }
    void Z() {
        printf("z = %d;\n",z);
    }
};

Make it C#-like.
Don’t include the header, re-declare the class in the CPP but with method-bodies.
When file include the header then he gets the extern fields\methods and etc from CPP.

It’s legal? I can’t predict problems from it. There is?

  • 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-12T20:04:21+00:00Added an answer on June 12, 2026 at 8:04 pm

    This falls into the realm of the One Definition Rule. In particular, a requirement that is put on multiple definitions across several TUs of a single program for the same class is:

    […] — each definition of D shall consist of the same sequence of tokens […]

    (Paragraph 5 of 3.2 One definition rule [basic.def.odr])

    So even if you ‘fixed’ the first version to declare the member functions inline to match the second version (where providing a definition of the members implicitly declares them inline) you would still run afoul of this rule: the function bodies are additional tokens that appear in the one but not in the other.

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

Sidebar

Related Questions

Consider this example: #include <iostream> class myclass { public: void print() { std::cout <<
Consider this example. public class myclass { public void... public int ... private class
Example: class MyClass { Composition m_Composition; void MyClass() { m_Composition = new Composition( this
Example: class C { public: void operator =(int i) {} }; class SubC :
Consider the following example : template<int X> class MyClass { public: MyClass(int x) {_ncx
I have the following code: [test.h] class MyClass { public: string Name; MyClass(); void
I have a ruby file as follows: module Example class Myclass def t_st Hello
Example: enum Flags { A, B, C, D }; class MyClass { std::string data;
Example class in pseudocode: class SumCalculator method calculate(int1, int2) returns int What is a
I came across this example class http://www.boost.org/doc/libs/1_49_0/libs/smart_ptr/sp_techniques.html#as_lock and I'm struggling with the syntax. class

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.