none
one-stop coding approach RRS feed

  • Question

  • Unlike C++,both JAVA and C# promote a one-stop coding approach to code maintanance. Please explain.
    Monday, March 22, 2010 8:06 AM

Answers

  • I think you are asking the above sentence from the book "Programming In C #"  By Balagurusamy.

    Further he said in the book that they (C# and Java) group classes, interfaces and implementations togetherin one file(unlike C++) so that programmers.

    It means that you cannot have two classes in one file in C++. Compiler will throw error in you did it.

    Consider the following code exist in a .cpp file(C++ program file).

    class MyClassA {
        public:
            void doSomething(MyClassB b) {};
    };

    class MyClassB  {
        public:
            void doSomething(MyClassA a) {};
    };

    Here MyclassA tries to use MyClassB in it as well as MyclassB. Though both classes exist in the same file, the compiler will throw error. To avoid this, you need to put the following statement at the first line.

    class B;

    But C# and Java does not have this restrictions. You can have multiple classes in a same file and access one class in another.
    Tuesday, March 23, 2010 7:09 AM

All replies

  • I think you are asking the above sentence from the book "Programming In C #"  By Balagurusamy.

    Further he said in the book that they (C# and Java) group classes, interfaces and implementations togetherin one file(unlike C++) so that programmers.

    It means that you cannot have two classes in one file in C++. Compiler will throw error in you did it.

    Consider the following code exist in a .cpp file(C++ program file).

    class MyClassA {
        public:
            void doSomething(MyClassB b) {};
    };

    class MyClassB  {
        public:
            void doSomething(MyClassA a) {};
    };

    Here MyclassA tries to use MyClassB in it as well as MyclassB. Though both classes exist in the same file, the compiler will throw error. To avoid this, you need to put the following statement at the first line.

    class B;

    But C# and Java does not have this restrictions. You can have multiple classes in a same file and access one class in another.
    Tuesday, March 23, 2010 7:09 AM
  • Thank you for your answer with clean explanation. I got clear idea about that sentence.
    Wednesday, March 24, 2010 12:35 PM