Studying C++ programming topics

Click For Summary

Discussion Overview

The discussion revolves around the prerequisites for learning advanced C++ topics such as classes, constructors, inheritance, and file handling. Participants explore whether understanding how to implement a class is necessary before delving into these advanced concepts.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants suggest that writing a C++ program typically involves using classes and constructors, implying that these concepts should be learned early on.
  • Others argue that it is possible to write simple C++ programs without defining custom classes, as demonstrated by examples using predefined classes like 'string' and 'fstream'.
  • A participant with a background in Java notes that C++ programming often involves subclassing within a GUI framework, which may not align with simpler C++ examples.
  • Another participant emphasizes the importance of understanding procedural programming before transitioning to object-oriented concepts in C++, especially for learners without prior programming experience.
  • Some participants express differing views on whether prior knowledge of C is beneficial or if it complicates the learning of C++.

Areas of Agreement / Disagreement

Participants do not reach a consensus on whether knowledge of class implementation is necessary before studying advanced C++ topics. There are multiple competing views regarding the teaching approach and the relationship between C and C++ programming.

Contextual Notes

Participants discuss various teaching methodologies and the background knowledge required for learning C++. There are references to the differences between procedural and object-oriented programming, as well as the impact of prior programming experience on learning C++.

sukalp
Messages
53
Reaction score
2
I wanted to know in c++
when we learn advance c++ like class,constructors,inheritance,data file handling we should know how to implement a class ? in c++ before studying these topics?
 
Technology news on Phys.org
Writing a C++ program means you are writing a class using at least one constructor and maybe inherit from some parent class depending on what you're trying to do. These are basic concepts which you would learn before you learn how to handle file io.

There are many tutorials available online, here is one such tutorial:

http://www.cplusplus.com/doc/tutorial/program_structure/
 
jedishrfu said:
Writing a C++ program means you are writing a class using at least one constructor

Maybe you're using "writing a class using at least one constructor" to mean something different from what I would mean by it. I don't see any such thing in this program:

C:
#include <iostream>
#include <string>

using namespace std;

int main ()
{
    string firstname;
    count << "What's your first name? ";
    cin >> firstname;
    count << "Hello, " << firstname << "!" << endl;
    return 0;
}

Although I have used the 'string' class by declaring the variable 'firstname', and have implicitly used the 'istream' and 'ostream' classes by using the predefined objects 'cin' and 'count' respectively, I have not defined (implemented) any classes of my own.

At this level, you can perform file I/O simply by using the predefined 'fstream' class which you can make available via '#include <fstream>'.

If you're writing a program using a predefined framework for e.g. a Windows GUI program, then you may very well have to write your code as classes with specific names and member functions (methods) that are "used" by the other parts of the framework. That's not a matter of the C++ language itself, but rather a matter of the structure of the framework.
 
jedishrfu said:
Writing a C++ program means you are writing a class using at least one constructor and maybe inherit from some parent class depending on what you're trying to do. These are basic concepts which you would learn before you learn how to handle file io.

There are many tutorials available online, here is one such tutorial:

http://www.cplusplus.com/doc/tutorial/program_structure/
thank you
 
jtbell said:
Maybe you're using "writing a class using at least one constructor" to mean something different from what I would mean by it. I don't see any such thing in this program:

C:
#include <iostream>
#include <string>

using namespace std;

int main ()
{
    string firstname;
    count << "What's your first name? ";
    cin >> firstname;
    count << "Hello, " << firstname << "!" << endl;
    return 0;
}

Although I have used the 'string' class by declaring the variable 'firstname', and have implicitly used the 'istream' and 'ostream' classes by using the predefined objects 'cin' and 'count' respectively, I have not defined (implemented) any classes of my own.

At this level, you can perform file I/O simply by using the predefined 'fstream' class which you can make available via '#include <fstream>'.

If you're writing a program using a predefined framework for e.g. a Windows GUI program, then you may very well have to write your code as classes with specific names and member functions (methods) that are "used" by the other parts of the framework. That's not a matter of the C++ language itself, but rather a matter of the structure of the framework.

thank you
 
Last edited by a moderator:
My apologies @jtbell as I'm a longtime Java programmer and haven't much done C++ in at least 20 years. Its true though that the C++ programs, we wrote were a part of a larger GUI framework where we subclassed our application from a standard class. The framework provided a connection to the many GUI events such as mouse movement, drag/drop and cut/copy/paste.
(see Taligent OS: https://en.wikipedia.org/wiki/Taligent)

To be fair though, using C++ in the manner of the simple examples shown is more about writing a C program that has been extended with C++ datatypes, operators and method overloading. C++ divided the community of programmers into application programmers and class designers. As programmers started to see the value of the Model-View-Controller design pattern. Class design because a central issue of C++ applications as you had to now consider how to use constructors, polymorphism and inheritance effectively.

In contrast, Java does not allow a programmer to simply write a main() method to get started instead you must begin with a class in order to create your program. Some recent language architectures based on Java such as Groovy or Scala do allow for writing code without a class but in fact, the code is wrapped with a hidden class.
 
sukalp said:
I wanted to know in c++
when we learn advance c++ like class,constructors,inheritance,data file handling we should know how to implement a class ? in c++ before studying these topics?

The whole thing in teaching C++ is - the usual one, the background in C family of languages. If the student / people learning programming, have no prior such knowledge or a fortiori, no programming background at all, the learning path must begin from first-things-first or in other words the procedural characteristics / features of the language (with or without comparisons to C) and then go to classes and the advanced topics based on them.

On the other hand, if learner has at least an intermediate knowledge of C, there's no point to talk about procedural things in depth other than the syntactic differences between C - C++ and syntactic sugar. So, effectively classes can be taught way earlier, because this way, learner, does not learn how to program but how to really program with C++.

Now, for the specific question about learning advanced concepts based on classes, it is obvious that one way or the other - referring to the above, student / learner has to know classes first.

As a side point, I don't find much truth in that someone already familiar (intermediate - advanced) with C, has to unlearn many things in order to learn good C++ programming, as is often said. I - many years ago, first learned a good deal of C (I was following a such discipline), and then introduced to C++ and I found no need in the procedure, to unlearn almost anything.
 
jedishrfu said:
My apologies @jtbell as I'm a longtime Java programmer and haven't much done C++ in at least 20 years. Its true though that the C++ programs, we wrote were a part of a larger GUI framework where we subclassed our application from a standard class. The framework provided a connection to the many GUI events such as mouse movement, drag/drop and cut/copy/paste.
(see Taligent OS: https://en.wikipedia.org/wiki/Taligent)

To be fair though, using C++ in the manner of the simple examples shown is more about writing a C program that has been extended with C++ datatypes, operators and method overloading. C++ divided the community of programmers into application programmers and class designers. As programmers started to see the value of the Model-View-Controller design pattern. Class design because a central issue of C++ applications as you had to now consider how to use constructors, polymorphism and inheritance effectively.

In contrast, Java does not allow a programmer to simply write a main() method to get started instead you must begin with a class in order to create your program. Some recent language architectures based on Java such as Groovy or Scala do allow for writing code without a class but in fact, the code is wrapped with a hidden class.
thanks i wanted to share you something https://coursetro.com/ it has java programming explaining concept and practising program and making android apps

once again thanks for helping
 
QuantumQuest said:
The whole thing in teaching C++ is - the usual one, the background in C family of languages. If the student / people learning programming, have no prior such knowledge or a fortiori, no programming background at all, the learning path must begin from first-things-first or in other words the procedural characteristics / features of the language (with or without comparisons to C) and then go to classes and the advanced topics based on them.

On the other hand, if learner has at least an intermediate knowledge of C, there's no point to talk about procedural things in depth other than the syntactic differences between C - C++ and syntactic sugar. So, effectively classes can be taught way earlier, because this way, learner, does not learn how to program but how to really program with C++.

Now, for the specific question about learning advanced concepts based on classes, it is obvious that one way or the other - referring to the above, student / learner has to know classes first.

As a side point, I don't find much truth in that someone already familiar (intermediate - advanced) with C, has to unlearn many things in order to learn good C++ programming, as is often said. I - many years ago, first learned a good deal of C (I was following a such discipline), and then introduced to C++ and I found no need in the procedure, to unlearn almost anything.
tthanks
 

Similar threads

Replies
86
Views
3K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
81
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 36 ·
2
Replies
36
Views
3K
  • · Replies 25 ·
Replies
25
Views
1K
Replies
65
Views
5K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K