IDE help(looking at return type)

hi guys long time since I have been on the forum almost a year at this stage,I took a break from programming but have been doing a little bit of java on the side,I'm glad I'm back but I'm having some trouble understanding the return types in c++

I am using eclipse as my IDE,now in java with eclipse it is pretty simple to read what type the function returns be it an int,string,void etc and it's also easy to see what arguments it takes but I don't understand this in c++ when using eclipse or any IDE to be honest it's the same in visual studio,

for example the size() function of the string class

I am trying to find out if it returns and int a string etc,I would guess an int but I can't see where it says this when I hover over the size function in the IDE this is what I get

size(void):std::cxx__11::basic_string<char,char_traits<char>,allocator<char>>::size_type

so how and where can I find what the return type is in the above line,I can't see a return type such as int,

if someone could explain how it works and how to find return types and arguments with the line above as an example

that would be much appreciated,I'm dying to get back into c++


thanks
size(void):std::cxx__11::basic_string<char,char_traits<char>,allocator<char>>::size_type

size_type is the relevant part. See this (section Member types):

http://www.cplusplus.com/reference/string/string/?kw=string

size_type is actually a typedef for size_t:

http://www.cplusplus.com/reference/cstddef/size_t/
I am trying to find out if it returns and int a string etc,I would guess an int but I can't see where it says this when I hover over the size function in the IDE this is what I get

size(void):std::cxx__11::basic_string<char,char_traits<char>,allocator<char>>::size_type

But it is telling you the type, it's a size_type.

Edit: Also trying to rely on the IDE to tell you the return type you should consider finding and reading actual documentation for the standard functions in question, the documentation will give you much more information than what the IDE has available.



Last edited on
wow thanks guys for the quick replies much appreciated =)

I never heard of member types,yes I will need to research them.

what does this part of the line mean

size(void):std::cxx__11::basic_string<char,char_traits<char>,allocator<char>>

firstly size(void) ?

then std::cxx__11::basic_string<char,char_traits<char>,allocator<char>>?

thanks
what does this part of the line mean

Without seeing the actual line I'll guess that that is how the compiler implemented whatever that line actually contained.


firstly size(void) ?

This possibly telling you that the size() member function takes no arguments.

then std::cxx__11::basic_string<char,char_traits<char>,allocator<char>>?

It looks like you're possibly trying to get the size() of a std::string.


thanks jlb much appreciated =)

what does the <char,char_traits<char>,allocator<char>> mean

it looks similar to that of generics in java
what does the <char,char_traits<char>,allocator<char>> mean
That are the template arguments.
thanks guys
Topic archived. No new replies allowed.