SlideShare a Scribd company logo
Updates About Questions The end
C++ Quiz
Felix Morgner
Computer Science
Hochschule f¨ur Technik Rapperswil
February 24, 2016
Updates About Questions The end
Updates About Questions The end
Updates About Questions The end
What we will see
Quirky stuff
Undefined Behavior
Unspecified things
Updates About Questions The end
Scoring
+1 per correct answer
+1 per correct reason
-1 per wrong answers
Updates About Questions The end
#include <iostream>
struct S {
int memfun() { return 1; }
int memfun() && { return 2; }
};
int main() {
S o{};
std::cout << o.memfun();
std::cout << S{}.memfun();
}
Updates About Questions The end
#include <iostream>
struct B {
virtual ~B() = default;
float a;
float b;
};
struct D : B {
float c;
};
int main() {
// assume: sizeof(float) = 4
// assume: sizeof(void*) = 8
std::cout << sizeof(B) << ’n’;
std::cout << sizeof(D) << ’n’;
}
Updates About Questions The end
#include <iostream>
struct S { };
int main() {
std::cout << sizeof(S) << ’n’;
}
Updates About Questions The end
#include <iostream>
auto f(unsigned long long & n) {
(***(int * * *)n)++;
}
int main() {
int constexpr n{43};
auto p1 = &n;
auto p2 = &p1;
auto p3 = (unsigned long long) &p2;
f(p3);
std::cout << (**(int * * *)p3 == &n) << ’ ’;
std::cout << *p1 << ’ ’ << n << ’n’;
}
Updates About Questions The end
#include <iostream>
int main() {
char const c{’c’};
char * ptr1;
char const * * ptr2{&ptr1};
*ptr2 = &c;
(*ptr1)++;
std::cout << c << ’n’;
}
Updates About Questions The end
#include <iostream>
int main()
{
https://github.com/fmorgner/cppquiz
std::cout << "cppugzhn";
}
Updates About Questions The end
#include <iostream>
struct S {
S() { std::cout << "c"; }
~S() { std::cout << "d"; }
};
int main() {
int i{};
mark:
S s{};
while(!i++) {
goto mark;
}
}
Updates About Questions The end
#include <iomanip>
#include <iostream>
#include <type_traits>
using namespace std;
int main() {
int i, &j = i;
[=]{
cout << std::is_same<decltype( j ), int &>()
<< std::is_same<decltype((j)), int const &>()
<< std::is_same<int &, int const &>();
}();
}
Updates About Questions The end
#include <iostream>
struct A {
A() = default;
A(A const &) { std::cout << "An"; }
};
struct B {
B() = default;
B(B const &) { std::cout << "Bn"; }
};
auto f(B const &) { }
int main() {
A a{};
B b{};
[=]{
std::cout << sizeof(a) << ’n’;
f(b);
}();
}
Updates About Questions The end
#include <iostream>
struct E {
template<typename ...Types>
E(Types const & ...) {}
};
template<typename ...Types>
auto println(Types const & ...args) {
E{(std::cout << args)..., std::cout << ’n’};
}
int main() {
using namespace std::literals;
println("C", ’+’, "+"s, "RocksMySocks");
}
Updates About Questions The end
#include <iostream>
template<typename ...Types>
auto call(Types const & ...) { }
template<typename ...Types>
auto println(Types const & ...args) {
call((std::cout << args)..., std::cout << ’n’);
}
int main() {
using namespace std::literals;
println("C", ’+’, "+"s, "RocksMySocks");
}
Updates About Questions The end
#include <iostream>
#include <string>
#include <vector>
int main() {
auto a = "cppug";
std::vector<std::string> v{a, a, a};
for(auto const & s : v) {
std::cout << s;
}
std::cout << ’n’ << v.size() << ’n’;
}
Updates About Questions The end
#include <iostream>
#include <string>
#include <vector>
int main() {
auto a = "cppug";
std::vector<std::string> v{{a, a, a}};
for(auto const & s : v) {
std::cout << s;
}
std::cout << ’n’ << v.size() << ’n’;
}
Updates About Questions The end
#include <iostream>
#include <string>
#include <vector>
int main() {
auto a = "cppug";
std::vector<std::string> v{{a, a}};
for(auto const & s : v) {
std::cout << s;
}
std::cout << ’n’ << v.size() << ’n’;
}
Updates About Questions The end
#include <iostream>
void f(long) {
std::cout << 1 << ’n’;
}
void f(float) {
std::cout << 2 << ’n’;
}
int main() {
f(4);
}
Updates About Questions The end
#include <iostream>
void f(int, int, int, int);
void f(int, int, int, int = 1);
void f(int, int, int = 2, int);
void f(int, int = 3, int, int);
void f(int = 4, int, int, int);
void f(int a, int b, int c, int d) {
std::cout << a << b << c << d << ’n’;
}
int main() {
f();
}
Updates About Questions The end
#include <iostream>
template<typename T>
void o(T) {
std::cout << 1;
}
template<typename T>
void f(T a) {
o(a);
}
void o(float) {
std::cout << 2;
}
int main() {
f(1.0f);
}
Updates About Questions The end
#include <iostream>
int main() {
auto x = 41; // Is this the right answer ??/
x = 42;
std::cout << x;
}
Updates About Questions The end
int main() <%<:=??)??<??(&:><%??(]<%??>();%>();}();%>
Updates About Questions The end
int main() <%
<:=??)??<
??(&:><%
??(]<%??>();
%>();
}();
%>
Updates About Questions The end
int main() {
[=]{
[&]{
[]{}();
}();
}();
}
Updates About Questions The end
Thanks
https://www.youtube.com/watch?v=rNNnPrMHsAA - Piotr
Padlewski - C++ WAT
http://cppquiz.org/ - C++ Quiz
http://olvemaudal.com/ - Olve Maudal
ISO14882:2014
Updates About Questions The end
Code and Slides
https://github.com/fmorgner/cpp-quiz
http://www.slideshare.net/fmorgner/cpp-quiz

More Related Content

What's hot

Operator overloading
Operator overloadingOperator overloading
Operator overloading
mohamed sikander
 
C++ file
C++ fileC++ file
1 borland c++ 5.02 by aramse
1   borland c++ 5.02 by aramse1   borland c++ 5.02 by aramse
1 borland c++ 5.02 by aramseAram SE
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
Chris Ohk
 
C- Programs - Harsh
C- Programs - HarshC- Programs - Harsh
C- Programs - Harsh
Harsh Sharma
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
AhalyaR
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
Farhan Ab Rahman
 
Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»
SpbDotNet Community
 
Static and const members
Static and const membersStatic and const members
Static and const members
mohamed sikander
 
2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
Aravindharamanan S
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
Vishvjeet Yadav
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
Chris Ohk
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
Chris Ohk
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
Chris Ohk
 
Sol10
Sol10Sol10

What's hot (20)

Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
C++ file
C++ fileC++ file
C++ file
 
1 borland c++ 5.02 by aramse
1   borland c++ 5.02 by aramse1   borland c++ 5.02 by aramse
1 borland c++ 5.02 by aramse
 
C++ Programming - 3rd Study
C++ Programming - 3rd StudyC++ Programming - 3rd Study
C++ Programming - 3rd Study
 
C- Programs - Harsh
C- Programs - HarshC- Programs - Harsh
C- Programs - Harsh
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
C++ TUTORIAL 2
C++ TUTORIAL 2C++ TUTORIAL 2
C++ TUTORIAL 2
 
Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»
 
Static and const members
Static and const membersStatic and const members
Static and const members
 
2 a networkflow
2 a networkflow2 a networkflow
2 a networkflow
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
C++ examples &revisions
C++ examples &revisionsC++ examples &revisions
C++ examples &revisions
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
Sol10
Sol10Sol10
Sol10
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 

Viewers also liked

Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
Sushil Mishra
 
Building reusable libraries
Building reusable librariesBuilding reusable libraries
Building reusable libraries
Felix Morgner
 
Tech Fest UK 2013 Technology Quiz
Tech Fest UK 2013 Technology QuizTech Fest UK 2013 Technology Quiz
Tech Fest UK 2013 Technology Quiz
Derrick Stomp
 
Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2AtakanAral
 
C++ class 12 cbse quiz programming (Compiled using Turbo C++)
C++ class 12 cbse quiz programming (Compiled using Turbo C++)C++ class 12 cbse quiz programming (Compiled using Turbo C++)
C++ class 12 cbse quiz programming (Compiled using Turbo C++)
Adarsh Pandit
 
Digital citizenship ~ presentation for schools (oct 2012)
Digital citizenship ~ presentation for schools (oct 2012)Digital citizenship ~ presentation for schools (oct 2012)
Digital citizenship ~ presentation for schools (oct 2012)
Stephen Carrick-Davies
 
Quick quiz on Objective-C
Quick quiz on Objective-CQuick quiz on Objective-C
Quick quiz on Objective-C
Stephen Gilmore
 
Digital Citizenship
Digital CitizenshipDigital Citizenship
Digital Citizenship
Kati W
 
IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)
IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)
IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)
ihsankallai
 
Computer Quiz (August 2013)
Computer Quiz (August 2013)Computer Quiz (August 2013)
Computer Quiz (August 2013)
Soham Banerjee
 
TCS IT WIZ 2013 Prelims Questions
TCS IT WIZ 2013 Prelims QuestionsTCS IT WIZ 2013 Prelims Questions
TCS IT WIZ 2013 Prelims Questions
Vittal Pai
 
IT Quiz Prelims
IT Quiz PrelimsIT Quiz Prelims
IT Quiz PrelimsSonal Raj
 
TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)
TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)
TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)
Pooja Shankar
 
Technology Quiz
Technology QuizTechnology Quiz
Technology Quiz
UC San Diego
 
Picture Quiz ppt
Picture Quiz pptPicture Quiz ppt
Picture Quiz ppt
Chanakya Karra
 
Chain sling
Chain slingChain sling
Chain sling
ANA ISABEL R.R.
 

Viewers also liked (18)

The Quiz Quiz Game
The Quiz Quiz GameThe Quiz Quiz Game
The Quiz Quiz Game
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 
Building reusable libraries
Building reusable librariesBuilding reusable libraries
Building reusable libraries
 
Tech Fest UK 2013 Technology Quiz
Tech Fest UK 2013 Technology QuizTech Fest UK 2013 Technology Quiz
Tech Fest UK 2013 Technology Quiz
 
Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2
 
C++ class 12 cbse quiz programming (Compiled using Turbo C++)
C++ class 12 cbse quiz programming (Compiled using Turbo C++)C++ class 12 cbse quiz programming (Compiled using Turbo C++)
C++ class 12 cbse quiz programming (Compiled using Turbo C++)
 
Digital citizenship ~ presentation for schools (oct 2012)
Digital citizenship ~ presentation for schools (oct 2012)Digital citizenship ~ presentation for schools (oct 2012)
Digital citizenship ~ presentation for schools (oct 2012)
 
Quiz show
Quiz showQuiz show
Quiz show
 
Quick quiz on Objective-C
Quick quiz on Objective-CQuick quiz on Objective-C
Quick quiz on Objective-C
 
Digital Citizenship
Digital CitizenshipDigital Citizenship
Digital Citizenship
 
IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)
IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)
IT QUIZ(KOZHIKODE SUB DISTRICT UP LEVEL)
 
Computer Quiz (August 2013)
Computer Quiz (August 2013)Computer Quiz (August 2013)
Computer Quiz (August 2013)
 
TCS IT WIZ 2013 Prelims Questions
TCS IT WIZ 2013 Prelims QuestionsTCS IT WIZ 2013 Prelims Questions
TCS IT WIZ 2013 Prelims Questions
 
IT Quiz Prelims
IT Quiz PrelimsIT Quiz Prelims
IT Quiz Prelims
 
TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)
TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)
TCS IT QUIZ QUESTIONS(tcstechbytes2012.blogspot.in)
 
Technology Quiz
Technology QuizTechnology Quiz
Technology Quiz
 
Picture Quiz ppt
Picture Quiz pptPicture Quiz ppt
Picture Quiz ppt
 
Chain sling
Chain slingChain sling
Chain sling
 

Similar to CPP Quiz

2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
kinan keshkeh
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practice
ranaibrahim453
 
C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
Abhishekkumarsingh630054
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
Mahbubay Rabbani Mim
 
C++17 not your father’s c++
C++17  not your father’s c++C++17  not your father’s c++
C++17 not your father’s c++
Patrick Viafore
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
C++ programming basics
C++ programming basicsC++ programming basics
C++ programming basics
Munazza-Mah-Jabeen
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
Marco Izzotti
 
Intro to C++
Intro to C++Intro to C++
Intro to C++
Ahmed Farag
 
SPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in CSPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in C
Mohammad Imam Hossain
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third Year
Dezyneecole
 

Similar to CPP Quiz (20)

2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Lab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practiceLab Manual IV (1).pdf on C++ Programming practice
Lab Manual IV (1).pdf on C++ Programming practice
 
901131 examples
901131 examples901131 examples
901131 examples
 
C++ practical
C++ practicalC++ practical
C++ practical
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
 
Oop1
Oop1Oop1
Oop1
 
C++17 not your father’s c++
C++17  not your father’s c++C++17  not your father’s c++
C++17 not your father’s c++
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
C++ programming basics
C++ programming basicsC++ programming basics
C++ programming basics
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
 
Intro to C++
Intro to C++Intro to C++
Intro to C++
 
SPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in CSPL 6.1 | Advanced problems on Operators and Math.h function in C
SPL 6.1 | Advanced problems on Operators and Math.h function in C
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Advanced C - Part 2
Advanced C - Part 2Advanced C - Part 2
Advanced C - Part 2
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third Year
 

Recently uploaded

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 

Recently uploaded (20)

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 

CPP Quiz

  • 1. Updates About Questions The end C++ Quiz Felix Morgner Computer Science Hochschule f¨ur Technik Rapperswil February 24, 2016
  • 4. Updates About Questions The end What we will see Quirky stuff Undefined Behavior Unspecified things
  • 5. Updates About Questions The end Scoring +1 per correct answer +1 per correct reason -1 per wrong answers
  • 6. Updates About Questions The end #include <iostream> struct S { int memfun() { return 1; } int memfun() && { return 2; } }; int main() { S o{}; std::cout << o.memfun(); std::cout << S{}.memfun(); }
  • 7. Updates About Questions The end #include <iostream> struct B { virtual ~B() = default; float a; float b; }; struct D : B { float c; }; int main() { // assume: sizeof(float) = 4 // assume: sizeof(void*) = 8 std::cout << sizeof(B) << ’n’; std::cout << sizeof(D) << ’n’; }
  • 8. Updates About Questions The end #include <iostream> struct S { }; int main() { std::cout << sizeof(S) << ’n’; }
  • 9. Updates About Questions The end #include <iostream> auto f(unsigned long long & n) { (***(int * * *)n)++; } int main() { int constexpr n{43}; auto p1 = &n; auto p2 = &p1; auto p3 = (unsigned long long) &p2; f(p3); std::cout << (**(int * * *)p3 == &n) << ’ ’; std::cout << *p1 << ’ ’ << n << ’n’; }
  • 10. Updates About Questions The end #include <iostream> int main() { char const c{’c’}; char * ptr1; char const * * ptr2{&ptr1}; *ptr2 = &c; (*ptr1)++; std::cout << c << ’n’; }
  • 11. Updates About Questions The end #include <iostream> int main() { https://github.com/fmorgner/cppquiz std::cout << "cppugzhn"; }
  • 12. Updates About Questions The end #include <iostream> struct S { S() { std::cout << "c"; } ~S() { std::cout << "d"; } }; int main() { int i{}; mark: S s{}; while(!i++) { goto mark; } }
  • 13. Updates About Questions The end #include <iomanip> #include <iostream> #include <type_traits> using namespace std; int main() { int i, &j = i; [=]{ cout << std::is_same<decltype( j ), int &>() << std::is_same<decltype((j)), int const &>() << std::is_same<int &, int const &>(); }(); }
  • 14. Updates About Questions The end #include <iostream> struct A { A() = default; A(A const &) { std::cout << "An"; } }; struct B { B() = default; B(B const &) { std::cout << "Bn"; } }; auto f(B const &) { } int main() { A a{}; B b{}; [=]{ std::cout << sizeof(a) << ’n’; f(b); }(); }
  • 15. Updates About Questions The end #include <iostream> struct E { template<typename ...Types> E(Types const & ...) {} }; template<typename ...Types> auto println(Types const & ...args) { E{(std::cout << args)..., std::cout << ’n’}; } int main() { using namespace std::literals; println("C", ’+’, "+"s, "RocksMySocks"); }
  • 16. Updates About Questions The end #include <iostream> template<typename ...Types> auto call(Types const & ...) { } template<typename ...Types> auto println(Types const & ...args) { call((std::cout << args)..., std::cout << ’n’); } int main() { using namespace std::literals; println("C", ’+’, "+"s, "RocksMySocks"); }
  • 17. Updates About Questions The end #include <iostream> #include <string> #include <vector> int main() { auto a = "cppug"; std::vector<std::string> v{a, a, a}; for(auto const & s : v) { std::cout << s; } std::cout << ’n’ << v.size() << ’n’; }
  • 18. Updates About Questions The end #include <iostream> #include <string> #include <vector> int main() { auto a = "cppug"; std::vector<std::string> v{{a, a, a}}; for(auto const & s : v) { std::cout << s; } std::cout << ’n’ << v.size() << ’n’; }
  • 19. Updates About Questions The end #include <iostream> #include <string> #include <vector> int main() { auto a = "cppug"; std::vector<std::string> v{{a, a}}; for(auto const & s : v) { std::cout << s; } std::cout << ’n’ << v.size() << ’n’; }
  • 20. Updates About Questions The end #include <iostream> void f(long) { std::cout << 1 << ’n’; } void f(float) { std::cout << 2 << ’n’; } int main() { f(4); }
  • 21. Updates About Questions The end #include <iostream> void f(int, int, int, int); void f(int, int, int, int = 1); void f(int, int, int = 2, int); void f(int, int = 3, int, int); void f(int = 4, int, int, int); void f(int a, int b, int c, int d) { std::cout << a << b << c << d << ’n’; } int main() { f(); }
  • 22. Updates About Questions The end #include <iostream> template<typename T> void o(T) { std::cout << 1; } template<typename T> void f(T a) { o(a); } void o(float) { std::cout << 2; } int main() { f(1.0f); }
  • 23. Updates About Questions The end #include <iostream> int main() { auto x = 41; // Is this the right answer ??/ x = 42; std::cout << x; }
  • 24. Updates About Questions The end int main() <%<:=??)??<??(&:><%??(]<%??>();%>();}();%>
  • 25. Updates About Questions The end int main() <% <:=??)??< ??(&:><% ??(]<%??>(); %>(); }(); %>
  • 26. Updates About Questions The end int main() { [=]{ [&]{ []{}(); }(); }(); }
  • 27. Updates About Questions The end Thanks https://www.youtube.com/watch?v=rNNnPrMHsAA - Piotr Padlewski - C++ WAT http://cppquiz.org/ - C++ Quiz http://olvemaudal.com/ - Olve Maudal ISO14882:2014
  • 28. Updates About Questions The end Code and Slides https://github.com/fmorgner/cpp-quiz http://www.slideshare.net/fmorgner/cpp-quiz