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

  • SEARCH
  • Home
  • 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 7709961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:59:34+00:00 2026-06-01T00:59:34+00:00

Imagine this code: class foo { foo fff; int m_id; f & work() {

  • 0

Imagine this code:

class foo
{
    foo fff;
    int m_id;

    f & work() { return fff; }
};

typedef foo f;

This will compile fine, but this one:

class QX_SERVICE_DLL_EXPORT Code
{
public:
    Code() : m_Id(0) { ; }
    virtual ~Code() { ; }

    inline long id() const { return m_Id; }
    inline void setId(long id) { m_Id = id; }

    inline const QString & code() const { return m_Code; }
    inline void setCode(const QString & code) { m_Code = code; }

    inline const QString & name() const { return m_Name; }
    inline void setName(const QString & name) { m_Name = name; }

    inline const QSharedPointer<Code> & parent() const { return m_Parent; }
    inline void setParent(const QSharedPointer<Code> & parent) { m_Parent = parent; }

    CodeList & children() { return m_Children; }

private:
    long m_Id;
    QString m_Code;
    QString m_Name;
    QSharedPointer<Code> m_Parent;
    qx::QxCollection<long, QSharedPointer<Code>> m_Children;

    friend void registerOrm(qx::QxClass<Code> & t);
};

typedef qx::QxCollection<long, QSharedPointer<Code> > CodeList;

What’s the difference? Why it doesn’t work with class Code and works with class foo?
Sorry for my broken English 🙂

I’m getting several errors, one of them is “Missing type specifier – int assumed” at CodeList & children() { return m_Children; }
I assume that typedef CodeList is not processed by the compiler when it is processing CodeList members in Code class, but I don’t understand why it is working for the first case. If I write the following:

class Code;

typedef qx::QxCollection<long, QSharedPointer<Code>> CodeList;

class QX_SERVICE_DLL_EXPORT Code
{
...

Then everything works fine.
BTW, I’m using MSVC 2010 compiler

  • 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-01T00:59:35+00:00Added an answer on June 1, 2026 at 12:59 am

    This is wrong:

    typedef CodeList qx::QxCollection<long, QSharedPointer<Code> >;
    

    You might mean:

    typedef qx::QxCollection<long, QSharedPointer<Code> > CodeList;
    

    I am pretty sure that the compiler should have provided an error message in that line of code, so my recommendation is read the error messages. If it hasn’t, then you might not have included the header where the typedef is declared… include it. Additionally in the header where it is declared, you cannot use it before it has been declared (C++ process top to bottom, or kind of, in most cases at least…)

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

Sidebar

Related Questions

Say I have some code like this: class Foo { public: Foo(int v) :
When I compile and run this code: #include <iostream> using namespace std; class Base
A question about c++ design and efficiency... Imagine this code - Database db; class
Imagine I have the following code: class A { [UsefulAttribute(foo)] B var1; [UsefulAttribute(bar)] B
Imagine this simple piece of code: class Constructor() { var string: String = _
Imagine this as the code from build.xml: <project name=test project> <target name=first> <echo>first</echo> </target>
Imagine I have this code: var myFunc1 = function(event) { alert(1); } var myFunc2
Imagine this sample java class: class A { void addListener(Listener obj); void removeListener(Listener obj);
Imagine this subroutine: sub test(&&) { my $cr1 = shift; my $cr2 = shift;
Looking at the JDK source code for LinkedHashMap, I noticed that this class is

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.