Jan 9, 2012 at 7:35am UTC
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
Jan 9, 2012 at 7:58am UTC
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 Jan 9, 2012 at 8:04am UTC
Jan 9, 2012 at 8:24am UTC
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
Jan 9, 2012 at 8:26am UTC
please help me get out of this problem and also tell me how to print the content of srl1 vector..
Jan 9, 2012 at 8:35am UTC
link_status_rsp lsr;
allready defined on line 23
Jan 9, 2012 at 8:37am UTC
yes after corrected .Even though it is giving same error as earlier.. please
Jan 9, 2012 at 8:46am UTC
Dear friend,
It is giving error while assign the value time itself. I ran in code in "codepad.org" also but same error
Jan 9, 2012 at 8:47am UTC
Thanks for fast and helpful suggestions
Jan 9, 2012 at 8:49am UTC
could you tell me please how to assign value to " value " variable and through srl1 vector..
Jan 9, 2012 at 9:35am UTC
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.
Jan 9, 2012 at 9:38am UTC
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 .
Jan 9, 2012 at 9:39am UTC
This error is showing at printing line ie std:: cout << ........
Jan 9, 2012 at 1:40pm UTC
@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?
Jan 9, 2012 at 1:48pm UTC
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 :)
Jan 10, 2012 at 4:48am UTC
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;
}
Jan 10, 2012 at 6:28am UTC
please urgent , any can solve this pls..