Hi,
I am trying to execute C++ program on zos.I tried a "Hello world" program without using "use namespace std;" it executed well and i could able to see the output of it. But while including "use namespace std;" its not executing.Is this mandatory for a C++ program on Zos??
Issue in declaratioin of "use namespace std;"
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: Issue in declaratioin of "use namespace std;"
You say it is "not executing". What does that mean? That you have not tried to execute it? That it executes but does not give expected results? That it excutes but fails during execution? That it failed to compile and/or link? And do not just say - "oh. it was this" but show us what went wrong.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
Re: Issue in declaratioin of "use namespace std;"
Sorry...
the basic C++ program which i executed on Zos is
the same program in which i have included the "using namespace std;" which is also a format for C++ program but while trying to execute it,this is not getting executed.
The error which i got while trying this is,
The text "namespace" is unexpected. "using" may be undeclared or ambiguous.
How to rectify it??
the basic C++ program which i executed on Zos is
Code: Select all
#include <iostream.h>
int main()
{
cout << "Hello World!";
return 0;
}
the same program in which i have included the "using namespace std;" which is also a format for C++ program but while trying to execute it,this is not getting executed.
Code: Select all
#include <iostream.h>
using namespace std;
int main()
{
cout << "Hello World!";
return 0;
}
The error which i got while trying this is,
The text "namespace" is unexpected. "using" may be undeclared or ambiguous.
How to rectify it??
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: Issue in declaratioin of "use namespace std;"
Not being a "curly-whirly" language programmer I am not sure about this but...from Googling 'using namespace std;' and the checking out a hit on the first page it may be that your using conflicts with your #include.
Edit [rest of post deleted as I am probably talking rubbish!}
Edit [rest of post deleted as I am probably talking rubbish!}
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
Re: Issue in declaratioin of "use namespace std;"
sorry i cant able get it properly.
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: Issue in declaratioin of "use namespace std;"
The z/OS XL C/C++ Language Reference manual indicates your posted source is not properly coded:
9.7 Unnamed namespaces
A namespace with no identifier before an opening brace produces an unnamed namespace. Each translation unit may contain its own unique unnamed namespace. The following example demonstrates how unnamed namespaces are useful.
#include <iostream>
using namespace std;
namespace {
const int i = 4;
int variable;
}
int main()
{
cout << i << endl;
variable = 100;
return 0;
}
In the previous example, the unnamed namespace permits access to i and variable without using a scope resolution operator.
Re: Issue in declaratioin of "use namespace std;"
Hi,
I tried for the program which you have given, but the same error prevails (The text "namespace" is unexpected. "using" may be undeclared or ambiguous).
The "std" is not recognised.
Do i need to include anything in the system libraries to recognise the "std" ??
I tried for the program which you have given, but the same error prevails (The text "namespace" is unexpected. "using" may be undeclared or ambiguous).
The "std" is not recognised.
Do i need to include anything in the system libraries to recognise the "std" ??
-
- Posts: 11
- Joined: Thu Feb 07, 2013 8:55 am
- Skillset: Assembler, Cobol, C, JCL
- Referer: google
Re: Issue in declaratioin of "use namespace std;"
Well,
the question is, how are you compiling?
Are you compiling as for c program, using the EDCC proc, or you compiling for a C++ program, using the CBCC proc?
Please note, the C only compile option does not recognize elements of the C++.
the question is, how are you compiling?
Are you compiling as for c program, using the EDCC proc, or you compiling for a C++ program, using the CBCC proc?
Please note, the C only compile option does not recognize elements of the C++.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 3
- 5060
-
by jrcox
View the latest post
Wed Jul 29, 2020 7:52 pm
-
- 1
- 1342
-
by jcdm
View the latest post
Mon Oct 24, 2022 6:10 pm
-
-
Code conversion issue while reading JCL using REXX
by vsgurunath » Fri Jun 19, 2020 10:19 pm » in CLIST & REXX - 11
- 4310
-
by vsgurunath
View the latest post
Thu Jun 25, 2020 4:08 pm
-
-
- 2
- 2268
-
by Terry Heinze
View the latest post
Tue Feb 15, 2022 9:13 pm
-
-
Issue Create/delete ALIAS IDC3013I and then IDC3012I
by jcdm » Thu Dec 05, 2024 9:26 pm » in VSAM/SMS - 1
- 1707
-
by willy jensen
View the latest post
Fri Dec 06, 2024 12:04 am
-