-
May 25th, 2011, 06:13 AM
#1
Vector
HI All,
I need some help in creating and accessing vector.
I have a class...
Class CMyPage{
MyPage::MyPage(Cstring strfilename, LONGLONG liEditpoint):
m_filename(strfilename)
,m_liEdit(liEditpoint)
{
}
Get FileName(return m_filename
Get EditPoint(return liEdit
private:
CString m_filename;
LONGLONG m_liEdit;
};
I will be creating a vector of this class as I need to increase at run time.
Class 2{
private:
std::vector<CMyPage> vecMyPage;
local function{
CString filename = "dkljfdkfj";
LONGLONG ni = < some number>;
CMyPage mypage(filename, ni);
vecMyPage.pushback(mypage);
}
It all works fine when i call this function 2 times. If it's called more, then the previous value in the vector(only the CString) become null or some rubbish character. How do I make sure the value does not go out of scope?
Thanks for any help.
P.S: the code is there just to give an idea of what i am trying to do. Hope you appreciate that my question here is more logical or understanding the concept.
-
May 25th, 2011, 06:43 AM
#2
Re: Vector
Managed to find out that the string value is going out of scope because its a LPCTSTR. I used CString and it worked !!
-
May 25th, 2011, 06:46 AM
#3
Re: Vector
Originally Posted by tarunk
I have a class...
Code:
Class CMyPage{
MyPage::MyPage(Cstring strfilename, LONGLONG liEditpoint):
m_filename(strfilename)
,m_liEdit(liEditpoint)
{
}
what is MyPage?
And if you really have a problem with your code then please show your actual code (using Code tags of course).
Otherwise you'll get "pseudo"-answers on your pseudo-code.
Victor Nijegorodov
-
May 25th, 2011, 08:29 AM
#4
Re: Vector
Just to add...
Originally Posted by tarunk
Managed to find out that the string value is going out of scope because its a LPCTSTR. I used CString and it worked !!
Interesting. The identifier LPCTSTR doesn't occur even a single time in the "code" you posted.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|