The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 vector<string> compile error

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
ThomasR Posted - 12/16/2013 : 05:28:58 AM
Hello, could some please hint me on my mistake?
I want to get a string array as return of a function. It does not compile with the error "line(0). no matching constructor" (I translated that error into english). But the other 2 functions for comparison work. If I comment the line below //(3), it compiles.

#include <Origin.h>

int test(){
	int bla=10;
	return bla;	
}

string test_string(){
	string testname = "blub";
	return testname;
}

vector<string> test_vectorstring(){
	vector<string> testvec = {
		"blub",
		"hello",
		"grrrrrr"
	};
	return testvec;
}


int getColIndex()
{
        //(1)
	int testint = test();

        //(2)	
	string testname = test_string();	
	
        //(3)
	vector<string> testvec = test_vectorstring();

	return 0;
}
3   L A T E S T    R E P L I E S    (Newest First)
Castiel Posted - 12/16/2013 : 08:27:53 AM
Instead of returning an array, I prefer to pass by reference and return its size:

int foo(vector<string> & v)
{
    // ....
    return v.GetSize();
}


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦
ThomasR Posted - 12/16/2013 : 06:12:55 AM
quote:
Originally posted by rlewis

I don't think there is an OC string constructor that accepts a string value ... The following seems to work ..


You are right. Thank you very much, I did not consider this.
Now I am just wondering why someone wouldn't implement a constructor analog to the others. This makes no sense but perhaps my view is too limited.
rlewis Posted - 12/16/2013 : 06:06:33 AM
I don't think there is an OC string constructor that accepts a string value ... The following seems to work ..


   vector<string> testvec;
   testvec= test_vectorstring(); 

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000