
Understanding Structs in C++
Authored by Adnan Ahmad
Computers
12th Grade
Used 3+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct syntax to define a struct in C++?
struct { memberName: dataType; } StructName;
struct StructName: dataType memberName;
StructName struct { memberName dataType; };
struct StructName { dataType memberName; };
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you access a member of a struct in C++?
Access members using the colon operator (::).
Members can only be accessed through a function.
Use the dot operator (.) or arrow operator (->) to access members of a struct.
Use the semicolon (;) to access members of a struct.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Can a struct in C++ contain member functions? If so, how?
No, a struct in C++ cannot contain member functions.
Only classes can have member functions in C++.
Yes, a struct in C++ can contain member functions.
Structs in C++ can only contain data members, not functions.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a nested struct and how is it defined in C++?
A nested struct is a type of variable in C++.
A nested struct can only contain primitive data types.
A nested struct is defined outside of any other struct.
A nested struct is a struct defined within another struct in C++. It is defined by placing the inner struct declaration inside the outer struct.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you declare an array of structs in C++?
struct MyStruct { int a; float b; }; MyStruct myArray[10];
struct MyStruct[] myArray;
MyStruct myArray = new MyStruct[10];
MyStruct myArray(10);
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between a struct and a class in C++?
Structs cannot have member functions; classes can.
Structs have public members by default; classes have private members by default.
Structs can inherit from other structs; classes cannot.
Classes are used for data only; structs are used for functions only.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you pass a struct to a function in C++?
You must always pass a struct by reference.
You can pass a struct to a function in C++ by value, by reference, or by pointer.
Structs cannot be passed to functions in C++.
You can only pass a struct by value.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
EMPTECH L4 Q3
Quiz
•
12th Grade
10 questions
Microcontroller
Quiz
•
11th Grade - University
14 questions
Input, output and storage de
Quiz
•
8th Grade - Professio...
14 questions
Topologías de red!
Quiz
•
12th Grade
10 questions
ZOOM QUIZ
Quiz
•
1st - 12th Grade
10 questions
Tin học 10 _ Bài 16 _Định dạng văn bản
Quiz
•
10th - 12th Grade
18 questions
TEST Bài 1_K12_Sách KNTT
Quiz
•
12th Grade
10 questions
Cos’è la ROM?
Quiz
•
6th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
10 questions
Probability Practice
Quiz
•
4th Grade
15 questions
Probability on Number LIne
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
6 questions
Appropriate Chromebook Usage
Lesson
•
7th Grade
10 questions
Greek Bases tele and phon
Quiz
•
6th - 8th Grade