Author Topic: Solved: Code Completion Problem with Objects  (Read 3858 times)

Offline Kyuur

  • Single posting newcomer
  • *
  • Posts: 2
Solved: Code Completion Problem with Objects
« on: April 08, 2014, 10:40:55 pm »
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
Code
class myClass
{
public:
    myClass(int x, int y);
}

Code
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
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.
« Last Edit: April 09, 2014, 01:09:13 am by Kyuur »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Code Completion Problem with Objects
« Reply #1 on: April 08, 2014, 11:09:32 pm »
If I change:
Header
Code
class myClass
{
public:
    myClass(int x, int y);
}
to:
Code
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?

Offline Kyuur

  • Single posting newcomer
  • *
  • Posts: 2
Re: Code Completion Problem with Objects
« Reply #2 on: April 09, 2014, 01:09:00 am »
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!