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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:50:40+00:00 2026-05-26T11:50:40+00:00

i am using Visual Studio 2010 Ultimate and i want to create a class

  • 0

i am using Visual Studio 2010 Ultimate and i want to create a class to read .ini files in C++. It is not hard for me but Visual underline method when it return reference to an object and the error message is not clear for me so I need some help.

I have two class. One, Tokenizer, which read .ini files and the second, Token, which represent one token like [Somethink].

In Tokenizer i created a method to add new Tokens to the std::list when there are found in the ini file.

Token Tokenizer::addToken(string name){
    Token newToken(name);
    data.push_back(newToken);
    return newToken;
}

I need that reference to add pairs key->value to it later. This is the contructor of Token:

Token::Token(string tokenName){
    name = tokenName;
}

And everything should by ok but it’s not. Visual Studio underline the word addToken in the code above saying that:

Error: declaration is incompatible with “error-type>
Tokenizer::addToken(std::string name)”.

But the declaration is

Token Tokenizer::addToken(string name); 

and class Token is also defined so it makes no sense to me. What is interesting when i change the type of returned value to VOID and remove the return instruction then everything is ok.

Please help. This is my first contact with references and Object programming in C++.

  • 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-05-26T11:50:41+00:00Added an answer on May 26, 2026 at 11:50 am

    Edit it turns out this was not the problem after all – it just could have been. Next time, prefer to post a minimal working example from the original code, not just some selected quotes.

    This would be easier if you showed more code. Using my psychic debugging abilities, I’m going to guess that Token is a nested class/struct. I.e., you need to define it like

    Tokenizer::Token Tokenizer::addToken(string name){
         Token newToken(name);
         data.push_back(newToken);
         return newToken;
    }
    

    I’ve guessed the namespace qualification to be Tokenizer::Token (but it might need to be something else)

    Note also that it is not necessary to fully qualify the nested types (if they would be locally visible from withing Tokenizer) for

    • method parameters
    • the method body

    Just the return type needs full qualification, IIRC

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

Sidebar

Related Questions

I am using Visual Studio 2010 Ultimate. I want to find out which methods
I'm using Visual Studio 2010 Ultimate. In a simple Windows application I just want
I am using Visual Studio 2010 Ultimate Beta 2. What is the relevant namespace/classes
I'm running Windows 7 Ultimate (64 bit) using Visual Studio 2010 RC. I recently
I want to be able to develop code using Visual Studio 2010. I just
Im using Visual Studio 2010 Ultimate and Im trying to convert some images using
I am using Visual Studio 2010 Ultimate Edition and I've installed the Beta 2
Environment: Visual Studio Ultimate 2010 Windows XP WPF Desktop Application using .NET 4.0 We
I'm making a Windows Forms application in Visual Studio 2010 Ultimate, but can't get
I'm using Visual Studio 2010 Ultimate, and it seems that I cannot suppress warnings

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.