The literal 0
has two meanings in C++.
On the one hand, it is an integer with the value 0.
On the other hand, it is a null-pointer constant.
As your setval
function can accept either an int
or a char*
, the compiler can not decide which overload you meant.
The easiest solution is to just cast the 0
to the right type.
Another option is to ensure the int
overload is preferred, for example by making the other one a template:
class huge { private: unsigned char data[BYTES]; public: void setval(unsigned int); template <class T> void setval(const T *); // not implemented template <> void setval(const char*); };
Related Posts:
- error: expected unqualified-id error: Meaning and fix? [duplicate]
- c++ compile error: ISO C++ forbids comparison between pointer and integer
- error: redefinition of class
- C++ Error: No match for ‘operator=’
- Identifier not found error on function call
- What is an ‘undeclared identifier’ error and how do I fix it?
- Identifier not found error on function call
- What is an ‘undeclared identifier’ error and how do I fix it?
- C ++ error: a expected initializer before [function name]
- invalid new-expression of abstract class type
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- error: redefinition of class
- C++ error: “Array must be initialized with a brace enclosed initializer”
- error: expected primary-expression before ‘)’ token (C)
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- Resolve build errors due to circular dependency amongst classes
- C++ error: definition of implicitly-declared
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- extra qualification error in C++
- Cannot open output file, permission denied
- Call to non-static member function without an object argument compiler error
- Error “Unterminated conditional directive” in cross-referencing headers
- multiple definitions error in c++ and solution to solve this issue
- Stray ‘\342’ in C++ program
- System not declared in scope?
- Error in assignment of member in read-only object
- error: ISO C++ forbids in-class initialization of non-const static member
- Error: expression cannot be used as a function?
- Unexpected end of file error
- virtual memory exhausted: Cannot allocate memory
- Compiler error C4430: missing type specifier – int assumed [duplicate]
- Is “delete this” allowed in C++?
- How to create a dynamic array of integers
- What does the explicit keyword mean?
- Expression must have class type
- What does “dereferencing” a pointer mean?
- What is a char*?
- Usage and Syntax of std::function
- Very basic C++ program issue – Invalid operands to binary expression
- Passing an array by reference
- Why use conio.h?
- Why is enum class preferred over plain enum?
- How to fix C++ error: expected unqualified-id
- How to track down a “double free or corruption” error
- Class name does not name a type in C++
- Is there a decent wait function in C++?
- streambuf::xsgetn and state flags
- C++ table alignment – cout and iomanip
- Debug assertion failed. C++ vector subscript out of range
- Inheriting constructors
- I’m getting an error “invalid use of incomplete type ‘class map’
- “Error: expression must have a pointer type” when using the “this” keyword
- This declaration has no storage class or type specifier in C++
- error: expected unqualified-id before ‘if’
- The #include
exists, but I get an error: identifier “cout” is undefined. Why? - Understanding “corrupted size vs. prev_size” glibc error
- Is the practice of returning a C++ reference variable evil?
- how to convert C# to C++
- What are helper functions in C++?
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- C++ String Variable Declaration
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- Why is my HelloWorld function not declared in this scope?
- What is the difference between include_directories and target_include_directories in CMake?
- Undefined reference to constructor
- How to add element to C++ array?
- expected constructor, destructor, or type conversion before ‘(’ token
- Passing as const and by reference – Worth it?
- expression did not evaluate to a constant- c++
- Generate SHA256 in c++
- A good and basic implementation of BigInt class in C++
- What is the C equivalent to the C++ cin statement?
- Convert char array to single int?
- https://stackoverflow.com/questions/3865946/error-generic-array-creation
- Does C++11 have C#-style properties?
- How to print a string in C++
- How to check if input is numeric in C++
- C++ Big Integer
- How do I create a random alpha-numeric string in C++?
- Learning to work with audio in C++
- C++ Void Function with File Stream Error
- sorting in std::map where key is a std::string
- no debugging symbols found when using gdb
- C++ Array of pointers: delete or delete []?
- ERROR: Control may reach end of non-void function /
- Warning : overflow in implicit constant conversion
- C++ multiline string literal
- Using cin to input a single letter into a char
- C++ calling base class constructors
- Why am I getting an ‘Else without previous if’ error within a for loop?
- Dynamic and static Scoping program differences
- How to fix the error “Windows SDK version 8.1” was not found?
- Is C++ Array passed by reference or by pointer?
- Compiling C++11 with g++
- set head to NULL (‘NULL’ : undeclared identifier)
- ERROR C2039: ‘vector’: is not a member of ‘std’
- Finding square root without using sqrt function?
- How do you clear a stringstream variable?
- Differences between unique_ptr and shared_ptr