示例#1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("This program doesn't compile in its present state.");
            // open a bank account
            Console.WriteLine("Create a bank account object");
            BankAccount ba = new BankAccount();

            ba.InitBankAccount();

            // accessing the balance via the Deposit() method is OK -
            // Deposit() has access to all of the data members
            ba.Deposit(10);

            // accessing the data member directly is a compile
            // time error
            Console.WriteLine("Just in case you get this far"
                              + "\nThe following is supposed to "
                              + "generate a compile error");
            ba.dBalance += 10;


            // wait for user to acknowledge the results
            Console.WriteLine("Press Enter to terminate...");
            Console.Read();
        }
示例#2
0
    public static void Main(string[] args)
    {
      Console.WriteLine("This program doesn't compile in its present state.");
      // Open a bank account.
      Console.WriteLine("Create a bank account object");
      BankAccount ba = new BankAccount();
      ba.InitBankAccount();

      // Accessing the balance via the Deposit() method is OK -
      // Deposit() has access to all of the data members.
      ba.Deposit(10);

      // Accessing the data member directly is a compile
      // time error.
      Console.WriteLine("Just in case you get this far the following is "
                      + "supposed to generate a compile error");
      ba._balance += 10;


      // Wait for user to acknowledge the results.
      Console.WriteLine("Press Enter to terminate...");
      Console.Read();
    }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("This program doesn't compile.");

            // Open a bank account.
            Console.WriteLine("Create a bank account object");
            BankAccount ba = new BankAccount();

            ba.InitBankAccount();

            // Accessing the balance via the Deposit() method is okay --
            // Deposit() has access to all the data members.
            ba.Deposit(10);

            // Accessing the data member directly is a compile-time error.
            Console.WriteLine("Just in case you get this far the following is "
                              + "supposed to generate a compile error");
            ba._balance += 10;

            // Wait for user to acknowledge the results.
            Console.WriteLine("Press Enter to terminate...");
            Console.Read();
        }