470,815 Members | 1,267 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

concatenate an integer with an object

5
Hi

I have to concatenate an integer to an object created.

something like this:

Expand|Select|Wrap|Line Numbers
  1. for(int i - 0; i< ac.size();i++)
  2. {
  3.         if (  ac[i]->jack  = A)
  4.         {
  5.               //set method
  6.         }
  7.         else
  8.         {
  9.               asset *AS[i] = createobj();
  10.         }
  11. }

i want to concatenate " [i] " with the object of asset ie " AS "

please help . working on c++ first time in a project where only enhancements are done ..

Thanks,
Apr 26 '07 #1
5 1370
AdrianH
1,251 Expert 1GB
Hi

I have to concatenate an integer to an object created.

something like this:

Expand|Select|Wrap|Line Numbers
  1. for(int i - 0; i< ac.size();i++)
  2. {
  3.         if (  ac[i]->jack  = A)
  4.         {
  5.               //set method
  6.         }
  7.         else
  8.         {
  9.               asset *AS[i] = createobj();
  10.         }
  11. }

i want to concatenate " [i] " with the object of asset ie " AS "

please help . working on c++ first time in a project where only enhancements are done ..

Thanks,
When you say concatenate, do you mean add to the end of the array/list/whatever? If so, you may be able to use push_back() if it is a STL vector. push_back() should also be available in other STL containers too.

Hope this helps. If I misunderstood, please clarify your question.


Adrian
Apr 26 '07 #2
r035198x
13,262 8TB
Hi

I have to concatenate an integer to an object created.

something like this:

Expand|Select|Wrap|Line Numbers
  1. for(int i - 0; i< ac.size();i++)
  2. {
  3. if ( ac[i]->jack = A)
  4. {
  5. //set method
  6. }
  7. else
  8. {
  9. asset *AS[i] = createobj();
  10. }
  11. }

i want to concatenate " [i] " with the object of asset ie " AS "

please help . working on c++ first time in a project where only enhancements are done ..

Thanks,
Also, perhaps
for(int i - 0; ....

was supposed to be for(int i = 0; ...?
Apr 26 '07 #3
malini
5
Sorry, i suppose my question was not clear.

First, yes it is supposed to be for(i = 0; ....) // typing error

now to the prb,
in the else condition i need to create new objects everytime the if condition fails
viz. if ( ac[1]->jack = A) ----> false
then i need tocreate something like this

asset *AS[1] = createobj();

loop back to chk for the ac[2]->jack = A ( suppose false)
then create
asset *AS[2] = createobj();

instead of the numbers i will say *AS[i]

i suppose i made it clear.

thanks
Apr 26 '07 #4
ilikepython
844 Expert 512MB
Sorry, i suppose my question was not clear.

First, yes it is supposed to be for(i = 0; ....) // typing error

now to the prb,
in the else condition i need to create new objects everytime the if condition fails
viz. if ( ac[1]->jack = A) ----> false
then i need tocreate something like this

asset *AS[1] = createobj();

loop back to chk for the ac[2]->jack = A ( suppose false)
then create
asset *AS[2] = createobj();

instead of the numbers i will say *AS[i]

i suppose i made it clear.

thanks
Shouldn't you have:
Expand|Select|Wrap|Line Numbers
  1. if (ac[1]->jack == A){}
  2.  
instead of:
Expand|Select|Wrap|Line Numbers
  1. if (ac[1]->jack = A){}
  2.  
?
Apr 26 '07 #5
AdrianH
1,251 Expert 1GB
Sorry, i suppose my question was not clear.

First, yes it is supposed to be for(i = 0; ....) // typing error

now to the prb,
in the else condition i need to create new objects everytime the if condition fails
viz. if ( ac[1]->jack = A) ----> false
then i need tocreate something like this

asset *AS[1] = createobj();

loop back to chk for the ac[2]->jack = A ( suppose false)
then create
asset *AS[2] = createobj();

instead of the numbers i will say *AS[ i ]

i suppose i made it clear.

thanks
In addition to ilikepython's observation, I cannot parse the line
Expand|Select|Wrap|Line Numbers
  1. asset *AS[2] = createobj();
What that looks like to me is almost like the declaration of a two element array of asset pointers being initialised to the return value of createobj(). But what I am stating cannot be the case as
  1. that is not how you initialise an array
  2. it has a scope of the else statement and looks rather useless, but may be just obfusticated

Perhaps you should just tell us what you are attempting to do without code and in words. Otherwise we may be here till next year.


Adrian
Apr 27 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

30 posts views Thread by priya | last post: by
3 posts views Thread by tirrell payton | last post: by
6 posts views Thread by Sheldon | last post: by
5 posts views Thread by Generic Usenet Account | last post: by
12 posts views Thread by Nezhate | last post: by
10 posts views Thread by Aaron Hoffman | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.