473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 1487
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

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

Similar topics

30
by: priya | last post by:
Hi How to concatenate two integer Values. Example Program : #include "Port.h" #include "BinaryConversion.h" # include "iostream.h"
3
by: Tom | last post by:
Hi I want to retrieve database data and concatenate them to a string. Here is my code .ToString()); //runtime error her } while (dr.NextResult()) string array =...
3
by: tirrell payton | last post by:
Hello all, I have a question about the concatenation operator in C#. For example, I want to concatenate an integer variable to a control. I have an integer, i. I have checkboxes, checkbox0 -...
6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
5
by: Generic Usenet Account | last post by:
I have been to recreate a problem that I am having with strings with the trivial code snippet given below. In the trivial code example, I am reading five lines from a data file, each line having...
1
by: kgk | last post by:
I would like to concatenate several file-like objects to create a single file-like object. I've looked at fileinput, however this returns a fileinput object that is not very file-like. ...
12
by: Nezhate | last post by:
Hi all, Is there any way to print a matrix's elements using a simple printf ? what I want as result is for example: if mat ={0,1,2,3} result must be: "0123". I tried this code: ...
10
by: Aaron Hoffman | last post by:
Hello, I'm hoping someone might be able to offer some guidance to my problem. I have one query in MS Access which consists of 2 tables joined by a SEQUENCE_ID. By joining the two tables I am...
1
by: Tony Bansten | last post by:
Assume I want to concatenate a literal text value and a variable value for a function parameter then the following does NOT work: objWorkbook.SaveAs("D:\work\v1_" + Filename) The variable...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.