The reason behind it is not given hence the question is asked.
Type: Posts; User: gaurav#
The reason behind it is not given hence the question is asked.
This warning can only hide a linker error of multiple definition which doesn't stand in this case. focus on this: how these definitions: int K=898 & extern int K=898 are different at function scope.
Check this out:
#include <iostream>
using namespace std;
extern int k =89;
int main() {
Initializing an extern variable defines that - the question is why definition - extern i =898; is different from definition - int i =898;
The code is throwing error despite 'i' being defined after initialization, why?
#include<iostream>
using namespace std;
the point of issue is: in code 1 the integer returned by toupper is rejected for initialization and in code 2 it is accepted -> in both the cases strings are involved.
maybe this clears better...
nope, I am doing exactly what I have done, i.e. direct initialization of string 's' in code 1 and conversion to upper case in code 2.
The error message when I use toupper(t[0]) is:
without using it, it is:
in this 1st code t[0] return 'char' so the compiler throws an error illegal conversion from 'char' to 'const char*' :
//CODE 1
#include<iostream>
#include<vector>...
#include <iostream> //CODE 1
using namespace std;
int main() {
char c[]="Hello"; //C-style string
cout<<sizeof(c);
return 0;
}
Hi, why the same code is having two different outputs (read it further):
#include<iostream>
#include<string>
using std::cin;
using std::cout;
I understand the cin-cout part but the comma seprating them is not clear, what functionality it adds?
One solution I got to take the input as String and then make a function to do the conversion job somewhat on the lines on atoi function but with base 8 for octal.
Apart from this can you please...
Since any variable can be declared multiple times & this underlying code is allocating memory only once, so why the re-declaration error?
int main(){ //code 1
externint i;
...
#include<iostream> //Call it 1st
using namespace std;
int main()
{
int i=019;
cout<<i<<endl;
return 0;
I have used member variables and operated on them with the help of member functions. Bu in one of the examples in C++ Primmer i found something like this:
Sales_item book; \\book...
in 1st shouldn't it throw some error since the operator << sends its right-hand-operands i.e. "hello") into the left hand operand i.e. ostream object cout & it should be asking for the...
why does these two statement behaving in the same manner?
(cout<<"hello"); //1st
cout<<"hello"; //2nd
SORRY I had type the code on a cell phone which lead to few auto-corrects along with some missing parts, here is the complete code:
#include<iostream>
using namespace std;
class a{
int...
Please paste the code as the link you have shared is not working
When a pointer points to an object of any class which is typecasted to that type, does it make the arguments of constructor behave like an array?
#include<iostream>
using namespace std;
...
1: If the base class has a virtual function and
then the derived class also has function under the same name, is it possible that even the derived class will have a virtual table despite the common...
char x[6]="hello";
char s[]=" world";
strcat(x,s);
Despite not giving enough space to x this code is giving output as "hello world". Why?
Now even on changing the code tho this, once it had printed " worldhello" but rest of the times it said runtime error.
#include<studio.h>
#include<string.h>
int main()
{
const char...
This is throwing a runtime error
#include<studio.h>
#include<string.h>
int main()
{
const char *x="hello";
char *s=" world";