GCC Debugging/g++/Warnings

< GCC Debugging < g++

deprecated conversion from string constant to 'char*'


friend declaration 'FUNCTION' declares a non-template function

note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here)
template <typename T>
class Foo {
public:
   T data;
   friend void Bar(Foo<T> &);
};

template <typename T> void Bar(Foo<T> &f) {
   cout << f.data << endl;
}

Possible fix?

template <typename TT> void Bar(TT &);

template <typename T>
class Foo {
public:
   T data;
   friend void Bar<>(Foo<T> &);
};

template <typename TT> void Bar(TT &f) {
   cout << f.data << endl;
}

ISO C++ says that these are ambiguous

ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second

multi-character character constant

char mrChar = '/0';  // instead of: char mrChar = '\0';

null argument where non-null required

strcpy(mrChar, '\0'); // won't work, null argument ('\0') supplied
strcpy(mrChar, ""); // will work?
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.