This question already has answers here:
Why does (i|o)fstream take a const char* parameter for a file name?
(5 answers)
Closed 8 years ago.
Is there any reasons - other than historical - to justify the fact std::ifstream/std::ofstream class take a char* and not a std::string to be constructed?
No. The constructor from std::string was added in C++11.
Related
This question already has answers here:
what will happen when std::move with c style array or not movable object
(2 answers)
Can std::move move a built-in types or c pointer or array
(1 answer)
What is std::move(), and when should it be used?
(9 answers)
Closed 8 months ago.
I want to do something like this:
int data[4] = {1,2,3,4};
int otherData[4];
otherData = std::move(data);
compiler says invalid array assignment, so how can I transfer values from data to otherData
This question already has answers here:
difference between two array declaration methods c++
(4 answers)
What is the difference between Static and Dynamic arrays in C++?
(13 answers)
Closed 10 months ago.
int numList1[10];
int *numList2 = new int[10];
I have seen too many solutions from others used the second way to assign array, do they work as the same?
This question already has answers here:
Which operator to overload in order to use my class in an if-statement? [duplicate]
(4 answers)
How do I override the bool operator in a C++ class?
(4 answers)
User Defined Conversions in C++
(4 answers)
Closed 4 years ago.
I am familiar with operator overloading, but a question popped up in my mind.
Is it possible to overload how an object behaves upon evaluating it without any operator? Such as:
Object foo;
if(foo){...}
So i can overload the evaluation with something like:
bool operator evaluation(){
bool isValid=false;
//Some instructions and conditions
return isValid;
}
There's probably little to no reason to do something like this, but I'm a bit new to C++ and I'm just exploring all nooks and crannies of it.
Thank you!
This question already has answers here:
Is there a difference between copy initialization and direct initialization?
(9 answers)
Direct Initialization vs Copy Initialization for Primitives
(4 answers)
Closed 9 years ago.
I read the following code in c++:
bool result(false);
is result initialized as false?
but are there any benefits to do it instead of:
bool result = false;
can anyone help?
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there a difference in C++ between copy initialization and direct initialization?
What's the difference between explicit and implicit assignment in C++
Simple as that. What is the difference between
std::string a("abc");
and
std::string a = "abc";