I want to print the contents of the vectors i have created that have strings pushed back to them. I have an initialize function that reads in two strings from a file and pushes them to two vectors respectively. I also have a toString function that is supposed to be used to print the vectors. How can i implement this toString function to test my results?
Oops i left out a character but this is what is returned after i try to compile:
1 2 3 4
EditDistance.cpp: In member function ‘std::string EditDistance::toString()’:
EditDistance.cpp:110:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
The only thing i have put in the toString function is cout<<sentence1.at(1)
There is no parameters for toString but i would assume it needs to return a string inside a vector
I don't think it should return something just change the function type to void and that warnig will go away (hopefully)
Is there any other error ? Is it compiled ?
I would like to use the functions as they are given to me because i am new to c++ and don't want to go off too far on my own. The goal of this program is to create an edit distance algorithm but i keep getting stuck. The next problem is to implement a 2d vector using something like:
I was told it would be easier to initialize all the contents of the 2d vector to -1 but whenever i try that i get these errors:
1 2 3 4 5 6 7
EditDistance.cpp: In member function ‘void EditDistance::initialize(Scanner&)’:
EditDistance.cpp:80:7: error: name lookup of ‘i’ changed for ISO ‘for’ scoping [-fpermissive]
for(i = 0; i < this->length; i++)
^
EditDistance.cpp:80:7: note: (if you use ‘-fpermissive’ G++ will accept your code)
EditDistance.cpp:82:9: error: ‘j’ was not declared in this scope
for(j = 0; j < this->length; j++)
I'd also like to note that the strings that we use as input for the vectors may be different lengths but we push back a dummy string of "XX" to the beginning of each string in the vector and push back the same dummy string to the end of each sentence until they are the same length of words.
Ex:
this is the first line
this is the second and final line
So the desired strings would be "XX this is the first line XX XX" and "XX this is the second and final line"