C++

Status
Not open for further replies.

electroRF

Member
Hi,

I'm wondering if there are C++ programmers here.

I set a goal to myself to study this month starting from today C++ from scratch to Design Patterns in 30 days - that is for Low Level RT Embedded applications.

I'd love getting any tips on how should the schedule look like and how would you recommend to practice the 'hard' stuff.

Thank you very much.
 
If you wan to use it for embedded applications, then plain old C should be more than enough. C++ is basically extension of C with object oriented programming in mind, and you will rarely need to use that with microcontrollers.
 
I have programmed in C++ before, but personally I much prefer Java.

Do you have any specific questions, or just putting feelers out?

Regards,
Matt
 
You have to be careful if you plan to study C++ online. There are lots of ugly and bad code there, because C++ is not a very well designed language. It adds more problems than solves drawbacks of C. Some people don't even consider C++ being a proper OOP language (I disagree with this, because I think you can apply OOP concepts even with ansi C).

Learning Design Patterns and Object Oriented Programming in general is a very good idea. Not sure if putting lots of time in learning C++ particularly is worth it.
I have not programmed C++ in over 5 years.. so that is all I have to say about it.

This is what the book "Expert C Programming - Deep C Secrets" says about C++:
The book is 20 years old so some of those things are probably fixed by now, especially the name-mangling problem (I hope). (google for "C++11")

But the final point is.. be careful if you study C++ online. Get a recently published book.
 
Last edited:
I would say, learning C++ just for the sake of it isn't a good idea.

If you want to get a basic understanding of OOP programming, there are other ways. For example, write few programs for an Android phone. It'll be fun to do.
 
For embedded or low level systems programming you should be exercise caution as OOP is a guard-rail that lets you take your mind off the narrow road and allows you to speed much faster than what's safe in a mine-field. It stops you from crashing early in the process but later when you do crash you go over the rail and die.

Stroustrup, Bjarne
 
Guys, thank you very much!

The reason I study it is for projects in Job, and I'm required to complete the studying this month.

They asked my to know well Inheritance, Design Patterns and Polymorphism.

Right now I just finished up Classes, const, References, Dynamic allocations, function overloading / default arguments, C++ casts and namespaces.

I got 4 weeks, hope to make it + exercise it


Regarding what you said that C is enough for Low Level, i meant RT Embedded.

many companies want RT Embedded C++ programmers.
 
Last edited:
many companies want RT Embedded C++ programmers.
It's fine if they are using ARM and pic32's .... Most on here use 8 bit micro's for small stuff.

I would agree that if you are working as a team C++ will be a better option on large embedded projects...
 
Guys, thank you very much!

The reason I study it is for projects in Job, and I'm required to complete the studying this month.

For a job we do what we have to but my feeling are more in this direction, OO skills are good for the programmer in general
but well-written C is substantially different from well-written C++ and the requirements for the compiler to create the best native machine language version of the source language that will communicate mainly with other machines on bare metal (infrastructure) instead something like human game programming should create a machine hierarchy like bits/bytes/state/sequence/function/data-flow instead of 'objects/methods' in low level programming where 'hiding' details is not always a good thing to do and you have to do it in 'C' anyway while officially using C++.
 
Last edited:
electroRF, after reading your latest posts, I think you are concentrating too much on the little details.. the name-mangling problem, for example, can be easily solved whenever you encounter it. No need to study it.
I would recommend you get a good book about Object Oriented Programming etc. Something like:

https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215
https://www.amazon.com/Implementing-Domain-Driven-Design-Vaughn-Vernon/dp/0321834577

The first one looks ugly, but is an excellent book. There are chapters related to electrical (embedded) design also.
I have not read the second one.. yet. But I will.. looks like a good book.
 
Last edited:
I believe you are familiar with "scope" in C. You can have global variables, variables inside a function etc. These are all different scopes.. usually defined by curly braces { }
Simply put, a namespace is a named scope.
Naming a scope allows you to refer to that particular scope in your code.

https://www.cplusplus.com/doc/tutorial/namespaces/
 
Hi T,
Thank you!

Actually yes, I know what namespace is, and your explanation made it clearer!

They are very common in libraries, because different libraries may define global objects with the same name, and therefore it's a must to use namespaces in order to avoid compiler errors of 'multiple definitions of an object' right?

Thanks to your comment, I now get the link.

If you define a static data member inside a class, static int m_cnt; , you'll still be able to define a global variable in your main program with the same name, and avoid compile error, and additionally, you could define same static int m_cnt; in other class.

You meant this?


-- BTW --
I see many time where static data member is used to count creations of objects - i.e.
1. the static data member is init to 0
2. the static data member is incremented by 1, in the Class' constructor

However, if you define a global object of a class, is it for 100% that the static data member is initialized BEFORE the constructor of the global object is called?

Because to my understanding, you do not know in advance the order of global objects' creation - so the Global Object could be created BEFORE the static data member was created and initialized.
 
Last edited:
I did work with C++ when it was the 'next' thing in the 90s but I along with most people discovered that OOP, encapsulation, strong typing, etc ... in general and not necessarily 'C++ the language' was the future in programming devices that have complex hierarchy of function. I'm brushing up my C++ skills again now that C++11 is finally able to handle machine level functions at compile-time in a sane way. Most of my work related programming tasks are legacy equipment maintenance engineering centered so the low-level capabilities of C could handle things easily but modern machines with 32 bit controllers require modern methods to keep them running.

http://www2.research.att.com/~bs/what-is-2009.pdf
http://electronicdesign.com/embedded/c11-and-ada-2012-renaissance-native-languages
 
Last edited:
Thank you for sharing NSA

I'm about to start off new project in C++ and OS in one month (will be told what when the time comes), and I'm expected to rule the language by then and OS concepts.

Any idea for practice is welcome

You still run projects in C++?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…