i'll try getline().thank you everyone.
Type: Posts; User: effa
i'll try getline().thank you everyone.
thats the function given to me.as far as i know iostream& is in stringstream as ss is in that form from the given test core.i could be wrong.
i tried but it says &inStream doesnt have .str() member
How do I convert from std::stringstream to std::string in C++?
Do I need to call a method on the string stream?
i tried .str() but didnt work.
//cpp
urgh dont quite understand what anon trying ti say there
mind to explain to me how this works? really confuse now. =_=
and what do you mean with the return type must be correct.what i did...
Vector &Vector ::operator =(const Vector &num);
doesnt the argument for the operator = have to be a Vector& not an int.
i tried to use pointer but it didnt work.
i also even tried to create a...
v is a vector<int> v.
im doing it in class.
i've done most of the part for the function
Vector &Vector ::operator [](const unsigned int index);
but my prob is how can i get the value...
here's the problem.
i was given a test case v[0]=1.
in order to implement operator[],i need to get the access the value it is refering to which is 1.but im not sure how?
//initial test...
thanks! i get it now :)
can anyone help me to understand how the compiler knows which objects we are refering to in class.
let say there are two objects with the same function methods:
obj a;
obj b;
and there is a...
so,is this right?
im assuming what you are trying to say is this can be any object which in this case is v1 and x is v2 .
if (this->somefunct != x->somefunct){
....}
//core unit test
//given 2 constructors
vector v1;
vector v2 (5,3);
//member functions : int dotProduct(const Vector &x)
int n = v1.dotProduct(v2)
hope anyone here can point out where my mistake was.tyvm. :)
h. file
class node {
public:
std::string data;
but i tried to return after the delete.it didnt work because of memory leak.to think of that,it does makes because if i did that means im trying to something that doesnt exist..correct me if im...
i am tryinh to create stack using linked list.
function below is to pop the last element and my problem is that the previous ptr is the same as current ptr though i did delete it after returning the...
hey i fix it! LOL..
after all the hours i spent on this stupid error..i figure out how to solve it..
i just need to change
#
//my bad!
anyone knows how to fix this...
i couldnt figure out why it does this everytime i tried to do a simple cout on the pointer that carries the data
cout << ptr-> data
hey iMalc.
do you mean i need to initialise the new array i created then i can use it later on?..but how?
most of the examples i've seen didnt initialise the new array.
another que: do you know...
i understand that..but in order to create stack that is not possible.i cant use STL or vector for this stack assignment..so im trying to understand how pointers works then...
the way i think is:...
hi all..
i'm a bit confused how the pointer works..
std::string n;
//is this right??
having issue with stack using linked list.
1) the num didnt give any value tho with the cout in count()
2) how to return string from pop()? i tried many ways like return ptr->s and stuff but...
if i want to use realloc..how should i define the type..is it char? isnt this means it will only look into each character in the string but not as a whole string?
i tried the append method and i dont think it will works the way i want it to.
void Stack :: push(std::string n){
//create new space when adding element
const char* n2= n.c_str();...
for this practice,we are not allowed to use othe standard lib besides the string class...so what i trying to do here to create a new space for a string.
any hints?
thanks.
this is what i got so far..
void Stack :: push(std::string n){
//create new space when adding element
if (size+1 < maxItems ){
maxItems *= 2;
char*array=new char[maxItems];