10. C++ Programming - Set And Get Function (C++ Class)

  Рет қаралды 7,467

Antonie Smith

Antonie Smith

Күн бұрын

Пікірлер: 17
@JulieWaima-z6b
@JulieWaima-z6b 9 ай бұрын
Great explanation ❤
@javanehmoghavi3954
@javanehmoghavi3954 10 ай бұрын
you explanation is awesome
@imransyed2632
@imransyed2632 3 жыл бұрын
Great Explanation brother!
@AntonieSmithVideos
@AntonieSmithVideos 3 жыл бұрын
Glad it was helpful!
@imransyed2632
@imransyed2632 3 жыл бұрын
how to set values for objects, dynamically? I want to take in number of students records to hold from user and set these values, can you show how?
@AntonieSmithVideos
@AntonieSmithVideos 3 жыл бұрын
I need you to first explain what you mean by setting the values of an object dynamically. When the object of type certain class has been created you want the private variable to be set to default values? You can look at the video of the constructor. You can also overload the constructor function to take parameters if need be. This will enable you to set private variables to specific values when the object is instantiated. Hope this helps.
@dudewheresmycar3618
@dudewheresmycar3618 2 жыл бұрын
How would I ask the user for input instead of hardcoding the name and student number Thanks
@AntonieSmithVideos
@AntonieSmithVideos 2 жыл бұрын
Easily by using the cin function. Main Function: Student Student1; string name_input; cout > name_input; Student1.setName(name_input);
@eddys2007yt
@eddys2007yt 3 жыл бұрын
good brother... your explanation (set/get) is done in (main). what if (set) is done by (main) and (get) is done by another class. I try always empty. help-help.
@AntonieSmithVideos
@AntonieSmithVideos 3 жыл бұрын
Hi Eddy, I don't know if I understand your question correctly. But here goes. When we have a class with functions (normally public) and variables (normally private), we want to interact specifically. If one class would call a get function of another class it will create a problems. Because, what if the class you are calling is not instantiated (object of type class). You cannot call functions in a class if there is no object. Analogy: Class = House Plan Object = Physical house built on the plan If the object you are calling from instantiated another object within itself, thats not a problem. But it a normal sense, rather stay away from classes calling other class functions.
@RedSparrow_FREEDOM
@RedSparrow_FREEDOM 2 жыл бұрын
why have you started with public? it is private by default so you can start without say private and later ypu can put public?!!!
@AntonieSmithVideos
@AntonieSmithVideos 2 жыл бұрын
You are correct that member variables and functions are by default private. Maybe should have started with private and then public. I think it is just better to state explicitly that member variables/functions are either private or public. Will avoid confusion in the long run. Especially when you are new to learning OOP programming.
@iteaahorma
@iteaahorma 29 күн бұрын
😅😅😅😅 very much working 2024
11. C++ Programming - Constructor (C++ Class)
11:09
Antonie Smith
Рет қаралды 11 М.
Friend functions and classes in C++ (Programming for beginners)
18:18
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 845 М.
Introduction To Classes And Objects | C++ Tutorial
11:49
Portfolio Courses
Рет қаралды 75 М.
Getters & Setters | C++ | Tutorial 30
12:41
Giraffe Academy
Рет қаралды 67 М.
C++ CLASSES & OBJECTS explained easy 🧍
10:54
Bro Code
Рет қаралды 40 М.
Function Templates | C++ Tutorial
10:54
Portfolio Courses
Рет қаралды 9 М.
Object Oriented Programming (OOP) in C++ Course
1:30:26
freeCodeCamp.org
Рет қаралды 2,6 МЛН
Classes & Objects | C# | Tutorial 25
13:25
Giraffe Academy
Рет қаралды 178 М.
Class Member Functions (aka Methods) | C++ Tutorial
7:18
Portfolio Courses
Рет қаралды 34 М.