Thread: how to do in c, what is record and object in pascal?

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    8

    how to do in c, what is record and object in pascal?

    Hello! I've searched a lot but i couldn't find how to create such struct wich has funtions in it. For example, struct called button has x,y,w and h. I can access these by button.x, button.y, etc. But how can i do a function in it, like button.draw();? In pascal these were called object's.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You need C++ if you want to do stuff like that.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    8
    ported my app to c++ now (little rewrite and renaming c to cpp), how do i do it in c++?

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    By asking on the c++ forum Look into member functions

  5. #5
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    Surely this can be done in C using pointers to functions?

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by Jez
    Surely this can be done in C using pointers to functions?
    It seams possible allthough it would be like re-inventing the wheal.

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    If you want to use OO design then use an OO language. Yes you can do OO in C and its a lot of fun if you are bored. But I definatly wouldn't recommend it for a new programmer.

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Quantum1024
    It seams possible allthough it would be like re-inventing the wheal.
    A wheal? Eeeew.

    Quzah.
    Hope is the first step on the road to disappointment.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by quzah
    A wheal? Eeeew.

    Quzah.
    haha my bad.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copies made of object during push_back()
    By Sharke in forum C++ Programming
    Replies: 3
    Last Post: 06-08-2009, 02:15 AM
  2. Little Help?
    By bbb543 in forum C++ Programming
    Replies: 31
    Last Post: 10-25-2008, 10:18 AM
  3. OleDbCommand.ExecuteScalar return problems
    By qwertiop in forum C# Programming
    Replies: 8
    Last Post: 05-07-2006, 10:19 AM