Studying C++ programming topics

In summary: C++11 features, you have to study C++11 standard. But there is no need to learn C++11 features before learning the basics of C++.In summary, you should learn the basics of C++ first before learning about classes, constructors, inheritance, and data files.
  • #1
sukalp
53
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
  • #2
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/
 
  • #3
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;
    cout << "What's your first name? ";
    cin >> firstname;
    cout << "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 'cout' 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.
 
  • #4
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
 
  • #5
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;
    cout << "What's your first name? ";
    cin >> firstname;
    cout << "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 'cout' 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:
  • #6
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.
 
  • #7
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.
 
  • #8
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
 
  • #9
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
 

What is C++ programming?

C++ is a high-level, general-purpose programming language that was developed by Bjarne Stroustrup in 1983. It is an extension of the C programming language and is used to create a wide variety of applications, including video games, operating systems, and web browsers.

Why is it important to study C++ programming?

Studying C++ programming is important for several reasons. It is a widely used language that is still relevant today, especially in industries such as game development and embedded systems. Additionally, learning C++ can help you understand the fundamentals of programming, which can then be applied to other languages. It also allows for low-level control of hardware, making it a powerful tool for creating efficient and high-performance applications.

What are some common topics covered in C++ programming courses?

Some common topics covered in C++ programming courses include data types, control structures, arrays, functions, classes, and objects. Additionally, students may also learn about memory management, pointers, file input/output, and exception handling.

What resources are available to help me study C++ programming?

There are many resources available to help you study C++ programming. These include online tutorials, textbooks, coding challenges, and online courses. You can also join online communities or forums to connect with other learners and get help and advice.

What are some tips for effectively studying C++ programming?

Here are a few tips for effectively studying C++ programming:

  • Practice, practice, practice: The best way to learn C++ is by writing code. Make sure to practice regularly to reinforce your understanding of concepts.
  • Start with the basics: It's important to have a strong foundation in the fundamentals before moving on to more advanced topics.
  • Read and understand code written by others: Reading and analyzing code written by experienced programmers can help you learn new techniques and best practices.
  • Take breaks: Programming can be mentally taxing, so make sure to take breaks and give yourself time to relax and recharge.
  • Ask for help: Don't be afraid to ask for help if you're struggling with a concept or problem. There are many online communities and forums where you can get support and advice from other programmers.

Similar threads

  • Programming and Computer Science
Replies
28
Views
2K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
Replies
65
Views
3K
  • Programming and Computer Science
3
Replies
81
Views
5K
  • Programming and Computer Science
2
Replies
36
Views
2K
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
8
Views
876
  • Programming and Computer Science
Replies
1
Views
727
  • Programming and Computer Science
3
Replies
89
Views
4K
Back
Top