Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9321683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:54:14+00:00 2026-06-19T03:54:14+00:00

The following code #include <iostream> #include <new> #include <cstring> #include <type_traits> template<typename T> void

  • 0

The following code

#include <iostream>
#include <new>
#include <cstring>
#include <type_traits>

template<typename T>
void is_pod(char* c)
{
    cout << "Type " << c;
    if(std::is_pod<T>::value)
        ::std::cout << " is POD" << endl;
    else
        ::std::cout << " is not!" << endl;
}

#define CHECK_TYPE(ty) ::is_pod<ty>(#ty)

struct POD_Parent{};
struct POD_Child : public POD_Parent{int y;};
struct POD_Child2 {int x; POD_Parent y; POD_Child ssd;};

int main()
{
    CHECK_TYPE(POD_Parent);
    CHECK_TYPE(POD_Child);
    CHECK_TYPE(POD_Child2);

Gives the following results: Which is strange!

Type POD_Parent is POD
Type POD_Child is not!
Type POD_Child2 is POD

How can POD_Child is not POD?! and POD_Child2 is POD?!!

Note that I compiled it using MinGW (using option -std=c++11) and it said that all of them are POD.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:54:16+00:00Added an answer on June 19, 2026 at 3:54 am

    According to [MSDN][1] a type that has a base class is not POD so POD_Child is not POD but for POD_Child2 its possibly some mistake of the compiler that ignore base class of ssd

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following code: #include <iostream> template <typename T, size_t N> void cal_size(T (&a)[N])
I have a the following code: #include <iostream> using namespace std; void func(char *
The following code #include <iostream> using namespace std; int main() { const char* const
I have the following code: #include<iostream> using namespace std; typedef void (*HandlerFunc)(int, int); HandlerFunc
I have following code: #include <cstring> #include <boost/functional/hash.hpp> #include <iostream> int main(int argc, char
Consider the following code snippet: #include <iostream> using namespace std; struct Element { void
Consider the following code: #include <iostream> using namespace std; int main() { int x,
Consider the following code: #include <iostream> struct foo { // (a): void bar() {
Consider the following code: #include <iostream> #include <memory> #include <vector> using namespace std; struct
I have the following code: #include <iostream> #include <vector> using namespace std; struct A{};

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.