Inserting value and printing the value

Pages: 12
Dear friends ,
Please could you help me to get out of this problem.

I want to assign a value and print it again. but it is giving error :
as
problem1.cpp:33: error: expected initializer before ‘srl1’

program :
#include<iostream>
#include<vector>
struct linkparam {

int value;
};
typedef std::vector <linkparam> link1;

struct link_status_rsp {
link1 ll;
};
struct status_rsp {

link_status_rsp rsp;
};

typedef std::vector<status_rsp> srl;


int main()
{
link_status_rsp lsr;

linkparam lp;
lp.value =90;

//link1.push_back(lp);
link_status_rsp lsr;
//lsr.l1 =
status_rsp sr;
sr.rsp.ll.push_back(lp);
//typedef std::vector<status_rsp> srl;
srl srl1
srl1.insert(srl.end(), sr);

//srl.push_back(sr);
}

and also please tell me how to print the value of vector "srl1"


Best Regards
BABU
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
program :
#include<iostream>
#include<vector>
struct linkparam {

int value;
};
typedef std::vector <linkparam> link1;

struct link_status_rsp {
link1 ll;
};
struct status_rsp {

link_status_rsp rsp;
};

typedef std::vector<status_rsp> srl;


int main()
{
link_status_rsp lsr;

linkparam lp;
lp.value =90;

//link1.push_back(lp);
link_status_rsp lsr;
//lsr.l1 = 
status_rsp sr;
sr.rsp.ll.push_back(lp);
//typedef std::vector<status_rsp> srl;
srl srl1
srl1.insert(srl.end(), sr);

//srl.push_back(sr);
}


I've just copyed.
what does this mean: ?
sr.rsp.ll.push_back(lp);

you're missing semicolon after srl1
Last edited on
Dear,
sr.rsp.ll.push_back(lp); ......According to me.

the variable "value" in linkparam structure should be passed to status_rsp structure for that, I used like that .

and even after corrected the semicolon after srl1. now the error is :


problem1.cpp:33: error: expected primary-expression before ‘.’ token
please help me get out of this problem and also tell me how to print the content of srl1 vector..
link_status_rsp lsr; allready defined on line 23
yes after corrected .Even though it is giving same error as earlier.. please
also tell me how to print the content of srl1 vector


1. create 2x const_iterator
2. create for loop
3. print values trought iterator to the screen within for loop.

for example:
1
2
3
4
5
typedef std::vector<status_rsp> srl;
srl::const_iterator iter = srl.begin();
srl::const_iterator iter2 = srl.end();
for(;iter != iter2; ++iter)
     cout << iter->ll.value;
Dear friend,

It is giving error while assign the value time itself. I ran in code in "codepad.org" also but same error
Thanks for fast and helpful suggestions
could you tell me please how to assign value to " value " variable and through srl1 vector..
1
2
3
4
5
6
7
8
9
srl1::iterator iter = srl1.begin();  //not const this time !
iter->ll.value = 30;
++iter;
iter->ll.value = 99;
++++iter;  // 2 time ahead;
iter->ll.value = 5;

for(iter; iter != srl.end(); ++iter)
     iter->ll.value = "value";

Dear friend , still error is the

#include<iostream>

#include<vector>
struct linkparam {

int value;
};
typedef std::vector <linkparam> link1;

struct link_status_rsp {
link1 ll;
};
struct status_rsp {

link_status_rsp rsp;
};

typedef std::vector<status_rsp> srl;


int main()
{


linkparam lp;
//lp.value =90;

link_status_rsp lsr;

status_rsp sr;
srl srl1;
std::vector<status_rsp>::iterator iter = srl1.begin(); //not const this time !
lp.value = 30;
iter->rsp.ll.push_back(lp);
++iter;
lp.value = 60;
iter->rsp.ll.push_back(lp);
++++iter; // 2 time ahead;
lp.value = 90;
iter->rsp.ll.push_back(lp);

for(iter; iter != srl->end(); ++iter)
std::cout<< iter->rsp.ll.value = "value"<<endl;





}
please could you help me to get out of this problem..

program: after little modification


error:: n function 'int main()':
Line 41: error: expected primary-expression before '->' token
compilation terminated due to -Wfatal-errors.


This is the sample and similar and part of the code of my program . So in my program when I ran the code It is giving the error as


Un able to match the operator << in { some big message is coming }

please tell me either please atleast .
This error is showing at printing line ie std:: cout << ........
Ok BABU, here is your code!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<vector>
#include<iostream>
using namespace std;

struct linkparam {
	int value;
};

typedef vector<linkparam> link1;
struct link_status_rsp {
	link1 ll;
};

struct status_rsp {
	link_status_rsp rsp;
};
typedef vector<status_rsp> srl;

int main()
{
	//Destiantion
	linkparam lp;
	lp.value =90;

	//Node1
	status_rsp sr;
	sr.rsp.ll.push_back(lp);

	
	//Node2
	srl srl1;
	srl1.push_back(sr);

	//Setup Access 
	link1::iterator iter2 = srl1.begin()->rsp.ll.begin();

	//list Destination value
	cout << "A vlue is: " << iter2->value;

	cin.ignore();
	return 0;
}


You old me a bottle of wiskey for that :D
1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
        linkparam lp;
	lp.value =90;
	link_status_rsp lsr;
	status_rsp sr;
	sr.rsp.ll.push_back( lp );

	srl srl1;
	srl1.push_back( sr);
        return 0;
}
@bluecoder

Your code is exactly the same as mine, except it does not print a value and does not contain comment's.

so what's your point exactly? :D

are you trying to say that your code is more efficient than mine?
Nope codekiddy .. actually i did not see your code and pasted mine ..sorry for that i should have looked at it . ..thanks for the code .. and sorry for not looking at your code first .. have a nice day :)
Dear friends,
Please look my code and when I trying to print the values of structure "status_rsp" using insertion operator overloading but it is giving "error as " no match operator << .

how to print value by using insertion operator overloading , because here ie in this sample code without overloading also printing but this is the piece of or sample of code , so once I executed there it is giving error as " no match operator for <<..

please any one tell me how to get out of this problem.


code:


#include<vector>
#include<iostream>
using namespace std;

struct linkparam {
int value;
};

typedef vector<linkparam> link1;
struct link_status_rsp {
link1 ll;
};

struct status_rsp {
link_status_rsp rsp;
friend std::ostream& operator<<(std::ostream& os , const status_rsp& sr)
{
os << "the value is " << sr.rsp;
}
};
typedef vector<status_rsp> srl;

int main()
{
//Destiantion
linkparam lp;
lp.value =90;

//Node1
status_rsp sr;
sr.rsp.ll.push_back(lp);


//Node2
srl srl1;
srl1.push_back(sr);

//Setup Access
link1::iterator iter2 = srl1.begin()->rsp.ll.begin();

//list Destination value
cout << "A vlue is: " << iter2->value;

cin.ignore();
return 0;
}










please urgent , any can solve this pls..
Pages: 12