Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6714409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:29:34+00:00 2026-05-26T08:29:34+00:00

This program compiles and runs on TC++ 3.0. Why don’t this program compile in

  • 0

This program compiles and runs on TC++ 3.0.

Why don’t this program compile in VC++2008Express?

#include <iostream>

using namespace std;

class MyClass
{
private:
    class MyNestedClass
    {
    private:
        int myInteger;

    public:
        MyNestedClass(int a)
        {
            myInteger = a;
        }
        void Show()
        {
            cout<<myInteger;
        }
    };
};

int main()
{
    MyClass::MyNestedClass myNestedClassObject(100);

    myNestedClassObject.Show();
}

The following messages are shown:

1>------ Rebuild All started: Project: Test, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'Test', configuration 'Debug|Win32'
1>Compiling...
1>Static_Data_Member.c
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(39) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(39) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(41) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(42) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(43) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(44) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(45) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(46) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(47) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(48) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(49) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(50) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(51) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(52) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(53) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(54) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(55) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(56) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdio(56) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(21) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2059: syntax error : ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(23) : error C2143: syntax error : missing '{' before ':'
1>c:\program files\microsoft visual studio 9.0\vc\include\cstdlib(23) : fatal error C1003: error count exceeds 100; stopping compilation
1>Build log was saved at "file://h:\Test\Debug\BuildLog.htm"
1>Test - 102 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:29:34+00:00Added an answer on May 26, 2026 at 8:29 am

    This is a C++ program, but you’ve given your source file a .c extension.

    By default, the Visual C++ compiler compiles .c files as C. Use a .cpp extension or compile with the /TP flag to compile the source as C++.

    However, even if you compile the source as C++, the program is still invalid. MyNestedClass is a private member type of MyClass, so you cannot construct an instance of it in main().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For this program #include <iostream> using std::cout; struct C { C() { cout <<
I am trying to compile the following program: #include <iostream> int main(){ std::cout <<
I just realised that this program compiles and runs (gcc version 4.4.5 / Ubuntu):
I am trying to compile a one-off script, an autogenerated C# program. This program
When I attempt to compile the output of this trivial lex program: # lex.l
when I'm trying to compile my c program it gives me this error warning:
when i run my program it compiles fine but when it runs i get
My program compiles and runs correctly but after the execution, my program crashes. Below
I'm getting this error when I try and compile my program on my school's
Ok so my program compiles and runs perfectly well, but the purpose is to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.