News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Solved: Code Completion Problem with Objects

Started by Kyuur, April 08, 2014, 10:40:55 PM

Previous topic - Next topic

Kyuur

Hi folks! I am using a standard installation of 13.12 off the main website, no settings changed other than importing a couple of libraries! Looked through code completion settings under Settings->Editor but could not find anything that looked related to my problem.

I'm a bit of a C++ noob, just started defining my own classes and creating objects with them. I have encountered somewhat of a problem when creating objects on the stack.

From what I understand, this is the typical way to create objects:

Header

class myClass
{
public:
   myClass(int x, int y);
}


Code

int main()
{
   myClass foo(2, 2);
}


While typing that out, after the first bracket I expected the constructor information to pop up. It does not, and in fact closes off the bracket right away, as if I am calling a function without parameters.

However, this works fine:

Code

int main()
{
   myClass foo = myClass(2, 2);
}


The information I want comes up as expected after typing the first bracket. I looked around to see if these were equivalent, as both compile and appear to work fine. Unfortunately, the second method actually is a lot less clean than the first, creating two objects and copying one to the other. Is there any way to fix this? I really like Code::Blocks, but I don't think I can deal with no constructor information showing up for me and having to load up the class file or documentation everytime I forget what variables are needed, or if there are alternate constructors.

Alpha

If I change:
Quote from: Kyuur on April 08, 2014, 10:40:55 PM
Header

class myClass
{
public:
    myClass(int x, int y);
}

to:

class myClass
{
public:
    myClass(int x, int y);
};

then both of your test cases work for me.  (Although, I presume you had it correct in your actual file, as you were able to compile.)

There have been some improvements to constructor calltips, and I cannot recall if they made it into 13.12.  Are you able to try a recent nightly?

Kyuur

My apologies, they were correct in the actual file as you suggested.

I put together a nightly and it does indeed work correctly! So I guess this is just a problem with the RC. For future reference if someone else encounters this I am using build 9744.

Thank you for the suggestion Alpha. I just hope I put MinGW together correctly.. my project was immediately crashing when I first tried built it with the nightly for no apparent reason. Seems to be fixed after resaving a couple files though!