Estudo de C++ Flashcards

Aprender C++ (56 cards)

1
Q

Dereference operator

A

Give access to real valor on the variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Reference operator

A

Give access to memory address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Keyword New

A

Creates and initializes objects with dynamic storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Keyword Delete

A

Erase variables after use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Struct

A

structure for grouping variables, from different types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Classes

A

Extension of struct concept, can have functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Data in structs

A

Atributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Functions in Classes

A

Also called methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Object

A

Takes attributes and methods from classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Object

A

We use it to access what is in classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Default classes

A

Everything after a declared class and before a specifier is PRIVATE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Scope operator

A

::

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Scope operator definition

A

To show that a function is a implementation from a member from a class, not a global function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Constructor

A

Special method called when a new object is created

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Using Constructor

A

Need to have the same name as the classes and no return valor, even VOID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Destructor

A

Called when an object is destroyed(when a function ends or when we use DELETE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Using Destructor

A

Need the same name as the class and a precede “~”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Destructor advantages

A

Good for memory releasing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Common practices in C++ with classes

A

Creating two separated files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

pragma once

A

Preprocessor directive to include the header once, regardless how many times he has been imported

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Declaring a classes as STATIC

A

We don’t need to instantiate a classes for using it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Static class example

A

“static int math::pow();”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Non static class example

A
"Math math = new Math();"
"math.pow();"
24
Q

Function in static class

A

Need to be static too

25
Constructor types
Most time are publics, but i can have private constructor too
26
How many constructs can I have?
Classes can have multiples constructors
27
What happens if I don't create a constructor?
My compiler creates a constructor automatically
28
How many default constructors a class have?
One, and just one
29
Default constructor example
``` class Person { public: Person(); ~Person(); }; ```
30
From what should I make sure to initialize my own constructor?
Because pointers and arrays can initialize with undefined values.
31
The complex reason for my own constructor?
When I have a class inside a class, my compiler is unable to initialize that member
32
Summarizing the 'this' operator - pt 1
This serves for refer to attributes and methods from a class
33
Summarizing the 'this' operator - pt 2
When you create an object(instantiate a class), you pass the values in the constructor and we can have methods overloading.
34
Summarizing the 'this' operator - pt 3(when use it)
Use the 'this' operator when I need to access anything inside a class
35
Keyword 'new'
It's used for allocate memory for an object in execution time
36
Keyword 'delete'
Releases memory after using an object and it's no more needed
37
Class Scope
In classes context, refer to member variables and member functions within the class definition
38
Inside a class
Every variable and function is available for the functions inside the class
39
Members modifiers
Every member from a class can have access to modifiers like 'private', 'public' and 'protected'
40
Private and public members availability
All the members are available for all members functions inside the class
41
Accessing members inside a class
When accessing I need to use the dot operator('.') or arrow('->')
42
Difference between dot and arrow
They have no difference, since they perform the same, but arrows it's normally used with pointers and dot with variables
43
Why use the arrow ->?
To replaces the following syntax: | (*a).b
44
Accessing statics classes
I need to use the class name like "Math::Sum() instead instantiating like "Math myMath" and after this "myMath.Sum()"
45
The compiler and class scope concept
The compiler knows what function he needs to call, because the object used it's associated with an specific class. He knows the difference between 'person.SayHello()' and 'dog.SayHello()'
46
Encapsulation concept in OOP
We can say that it allows to include data and functionalities in a single package.
47
The second definition of encapsulation
It's to hide or restrict data. For example we don't want to a Person class User defines the variables "firstName", 'lastName' and age directly, only using the constructor
48
A good practice within encapsulation scope
A good practice is to provide public functions to allow classes users to modify values, but indirectly
49
Using a public function to modify allow me to do...
M, as a programmer, control how the users data are processed
50
An example of treated data...
I can use a function to check if a user passed a negative value or a character instead a valid value for an age variable
51
Resuming encapsulation
When using it, we define how attributes and methods are accessed
52
Limiters...
private, public and protected
53
The important part of encapsulation?
That the user don't see how we define values or validates data
54
The encapsulation analogy
We don't need to know how a motor inside a car works, I need only to know how to drive him
55
Namespaces
He acts like a container, we put variables, classes or another identifiers to avoid name conflicts
56
Namespaces example: cout
He exists only in the std scope, that's why we use: std::cout or using namespace std; cout << 'Hello world' << endl;