[Discuss] SemiOT - Question for the C++ gurus

pw p.willis at telus.net
Mon Mar 5 08:56:31 PST 2007


Adam Parkin wrote:
> pw wrote:
>> Is this your homework............?
> 
> Well if you consider a C++ wrapper class for the GNU C Readline library 
> routines to be (hopefully) eventually used in your grad supervisors 
> research work to be homework, then yes, it is. =;->
> 
>>       ///should set this to a default array value
>>       static std::vector<std::string> m_vec;
>>
>>       myvec(std::vector<std::string> vecIn = m_vec):privVec(vecIn){ }
> 
> Is that the only way though, to create a separate "dummy" vector?
> 
> Thanks....


You could also set m_vec to a value before instantiation
as an external variable or constant.

ie:


////namespace required(???)

std::string blah[]={"a","b","c","yada"};
size_t sz = sizeof blah / sizeof *blah;

///this is now external and set to a value
static std::vector<std::string> m_vec(blah, blah+sz);

using namespace std;

class SomeClass
{
	myvec(std::vector<std::string> vecIn = m_vec):privVec(vecIn){ }
	///....etc
};


Peter



More information about the Discuss mailing list