I'm having some trouble passing strings by reference.
Below is some code:
So yeah, I get these error when I try to use the "guessConsonant" function:Code:int guessConsonant(string,string&); //function prototype ... .. . //function call (mysteryWord is declared as a normal string) TotalSoFar = guessConsonant(rWord, &mysteryWord); ... .. .. //function header int guessConsonant(string currentWord, string &mWord)
Basically, all I want to be able to do is pass a string to a function, manipulate the string inside the function, and have the changes affect the original string I passed to the function(passing by reference, right?) and for some reason my compiler won't accept what I'm giving it. So any help would be vastly appreciated.Code:wof2.cpp: In function `int main()': wof2.cpp:49: conversion from `string *' to non-scalar type `basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >' requested wof2.cpp:8: in passing argument 2 of `guessConsonant(basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >, string &)' wof2.cpp: In function `int guessConsonant(basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >, string &)': wof2.cpp:105: no match for `*basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> > &'



LinkBack URL
About LinkBacks


