Taner Şenyurt

Kişisel gelişim sitesi…

Difference between C++ Class and C struct

May14

C struct and C++ class structure is similar but by the default they have a difference in data hiding.
In struct doesn’t provide data hiding by default but class provides data hiding by default.
And the other difference is, class provides us to polymorphism and inheritance features.
We said class structure data hiding is coming default but what it means?
It means when we have a struct it is public by default so we can access our struct model wherever are we

  1. struct car{
  2. static int *model;
  3. int *horsePower;
  4. string *producer;
  5. }
  6. car myCar;

By myCar i can access my model,horsePower or producer because it works like public variable but same structure with class
like Read the rest of this entry »

posted under C & C++, Programming | Comments Off

Gcc 4.3 and Header issues

May13

I’m using gcc 4.3.3 version and nowadays i’m trying to write hybrid file transfer system with c++ on Linux.The problem is i used to use some function in c or c++ like strcmp() with including string library but now when i try to compile I’m getting some error like
error: ‘strcmp’ was not declared in this scope
Simple example code
In gcc 4.1 version i can compile this code without any error or warning

  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4. main()
  5. {
  6.         if(!strcmp("gccHeaderIssue","gccHeaderIssue"))
  7.         {
  8.         cout< <"kelimeler ayni"<<endl;
  9.         }
  10. }
  11.  

Read the rest of this entry »