C++ Programming Quiz | Challenge Your Skills with Our Thread-based Quiz

  • C/C++
  • Thread starter powergirl
  • Start date
  • Tags
    C++ Quiz
So, my interpretation of the question is that they are asking about implicit functions that can be called without defining them (just like isspace and isdigit). The ones you mentioned, cannot be called unless you define them.And what is your interpretation of "implicit"?In summary, the conversation covers various topics related to C++ programming, including the development and features of the language, rules for a quiz game, different types of variables, bitwise operators, and the differences between structs and classes. The conversation also discusses virtual functions and destructors, special functions that a C++ compiler can create implicitly, and the dangers of using certain functions from the <cctype> library. The conversation also delves into the interpretation of the term "implicit"
  • #1
powergirl
Let me start a Quiz based on c++ programming in this thread.
You are requested to give the right answer in quotes;
RULE:
No special rules are there.Anyway,
>>The person who tells the right answer must post the next question,No one must post Q's in between.
The person who answers must post a question,next to Ur answer.

:approve:Think and answer...:approve:
 
Technology news on Phys.org
  • #2
Let me start from easy Q's;

1)C++ programming language was developed at...?
 
  • #3
Bell Labs, and it had been called C with _____...?
 
  • #4
Classes

Can't come up with anything tougher: Who invented the language?
 
  • #5
Stroustrup (if that is spelled correctly)

The ++ in C++ refers to _____
 
Last edited by a moderator:
  • #6
++ is shorthand of +=1 which C++ implements.

List the different types of variables that can be called.
 
  • #7
Can be called?

Hmm...
#1: char, short, int, long, _int64
#2: unsigned char, unsigned short, etc
#3: char[], short[], int[], etc
#4: char *, short *, int *, etc
#5: const char *, const short *, etc
#6: char * const, short * const, etc
#7: const char * const, etc
#8: char **, short **, etc
#9: const variations of #8
#10: char[][], etc

I'm not sure if there are variations that mix [] and *, I guess there would be, like (char*)[].

Then:
#11: float, double, long double
#12: float[], double[], etc
etc

Then obviously structs and classes are types. I've probably missed a bunch.

List the bitwise operators of C++.
 
  • #8
You forgot "void *". Even though there can't really be a variable of type void, you can certainly have a pointer to one.

Gotta love C++.
 
  • #9
verty said:
List the bitwise operators of C++.

& - and
| - or
^ - xor
~ - not (bitwise)
>> - shift right
<< - shift left

What does the following code fragment do?

(void *(*)(...))
 
Last edited:
  • #10
Don't forget fun types like

int (* (*[10]) (long, void*) ) (const char*, int *[])

!
 
  • #11
Hurkyl said:
Don't forget fun types like

int (* (*[10]) (long, void*) ) (const char*, int *[])

A generally malformed question, I think. It was a little too wide open.

Managed to translate my typecast into English, yet?
 
  • #12
void *(*)(...) ...a function pointer to a function that returns some buffer.

[0] What is the main difference between C and C++
[1] What does :1 do in a variable declaration.
 
  • #13
twisting_edge said:
What does the following code fragment do?

(void *(*)(...))
It uses C to do a job in C++ when it really it shouldn't be used, it uses the dreaded void pointer and a variable argument list.

neurocomp2003 said:
[0] What is the main difference between C and C++
[1] What does :1 do in a variable declaration.
0)see neutrino's post.
1)It's a bit field.

What is the only difference between a struct and a class?
 
  • #14
Struct is default public, class is default private.

What's the difference between a virtual destructor and a virtual function?
 
  • #15
Virtual Functions and Destructors

A virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. It is one that is declared as virtual in the base class using the virtual keyword. The virtual nature is inherited in the subsequent derived classes and the virtual keyword need not be re-stated there. The whole function body can be replaced with a new set of implementation in the derived class

A virtual destructor is one that is declared as virtual in the base class and is used to ensure that destructors are called in the proper order. It is to be remembered that destructors are called in the reverse order of inheritance. If a base class pointer points to a derived class object and we some time later use the delete operator to delete the object, then the derived class destructor is not called.


?CAN U NAME THE SPECIAL FUNCTIONS A C++ COMPILER CAN CREATE IMPLICITY?o:)
 
  • #16
powergirl said:
If a base class pointer points to a derived class object and we some time later use the delete operator to delete the object, then the derived class destructor is not called.

This got a bit confusing. When destructing an object, you have to call the correct destructor; the virtual destructor plays the same role as virtual methods. Virtual destructors are useful when deleting the objects through a base pointer (like virtual methods are useful when calling the methods through a base pointer).

So in the end, the difference between virtual destructors and virtual methods is the same between plain destructors and plain methods.


powergirl said:
?CAN U NAME THE SPECIAL FUNCTIONS A C++ COMPILER CAN CREATE IMPLICITY?o:)

Default and copy constructors, destructor and assignment operator.



Why using isspace(), isdigit(), etc, from <cctype> is dangerous? What's the safe alternative? (Hint: find out why char is different from signed char and unsigned char)
 
  • #17
DanielKO said:
Default and copy constructors, destructor and assignment operator.
At the very least, you missed the comma operator. (Does new, new[], delete, and delete[] count too? Hrm)
 
Last edited:
  • #18
Hurkyl said:
At the very least, you missed the comma operator. (Does new, new[], delete, and delete[] count too? Hrm)

The default comma operator is just a sequence operator, that does absolutely nothing. If you are going to count it as an "implicit function", so does the add (+), increment (++), multiply (*), etc. :)

I don't think new and delete count as "implicit"; I consider them built-in, just like the operators on primitive types. In fact, the compiler won't generate any code, it will just call the implementation provided by the standard library - that's why you can replace them through <new> (as the linkage of the standard library happens after the symbols were resolved); so new and delete are as implicit as malloc and free.

BTW, right after posting, I checked my copy of the standard to make sure, and it also lists the implicit functions the same way I did. So anything beyond this is a matter of interpretation of what "THE SPECIAL FUNCTIONS A C++ COMPILER CAN CREATE IMPLICITY" means.
 
  • #19
DanielKO said:
The default comma operator is just a sequence operator, that does absolutely nothing. If you are going to count it as an "implicit function", so does the add (+), increment (++), multiply (*), etc. :)
If x and y are objects of your class, you cannot write x + y unless you explicitly define operator+, and similarly for the other functions you mentioned. On the other hand, you can write x, y without providing an explicit definition of operator,. :tongue:
 
  • #20
Hurkyl said:
On the other hand, you can write x, y without providing an explicit definition of operator,. :tongue:

Because the plain comma operator is exactly the same present in the C language: it does nothing (other than separating two expressions by a sequence point, and evaluating to the second expression). Maybe you would like to consider the (void) conversion operator as "implicitly created by the compiler"? After all, you can write (void)x; without providing an explicit definition.

You are considering a C language construct as an "implicitly created function".
 

1. What is the purpose of a C++ Programming Quiz?

A C++ Programming Quiz is designed to test and challenge a person's skills and knowledge in the C++ programming language. It provides an opportunity for individuals to evaluate their understanding of the language and identify areas for improvement.

2. How is the C++ Programming Quiz structured?

The C++ Programming Quiz typically consists of a series of multiple-choice questions or coding challenges that require the use of C++ programming concepts. It may also include questions that test a person's understanding of data structures, algorithms, and programming principles.

3. Can I take the C++ Programming Quiz more than once?

Yes, most C++ Programming Quizzes allow for multiple attempts. This allows individuals to practice and improve their skills over time. However, some quizzes may have a limit on the number of attempts allowed.

4. Are there any prerequisites for taking the C++ Programming Quiz?

Some C++ Programming Quizzes may have prerequisites, such as a certain level of programming experience or familiarity with specific concepts. It is important to read the instructions and requirements carefully before attempting the quiz.

5. How can I prepare for the C++ Programming Quiz?

To prepare for the C++ Programming Quiz, it is recommended to review and practice C++ programming concepts, data structures, and algorithms. Online tutorials, courses, and practice exercises can be helpful in preparing for the quiz. It is also important to have a good understanding of the C++ syntax and common programming patterns.

Similar threads

  • Programming and Computer Science
Replies
8
Views
863
Replies
8
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
Replies
2
Views
1K
  • Programming and Computer Science
Replies
29
Views
3K
Replies
37
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Math Proof Training and Practice
2
Replies
42
Views
6K
  • Programming and Computer Science
Replies
9
Views
1K
  • Math Proof Training and Practice
3
Replies
86
Views
9K
Back
Top