Results 1 to 5 of 5

Thread: Interface in C programming

  1. #1
    Join Date
    May 2008
    Posts
    255

    Interface in C programming

    Hi,

    I am so confused to know about the interfaces.The Interface concept is used in the object oriented programming and I got something new from my friend which I think would be very interesting so I need to know the really the construction and actual concept of this particular topic.I am very excited know about this.


    Thanks.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Interface in C programming

    Hello dude,

    I got your question and I know you are really more and more excited to know the answer of constructing interface in c language where as the interface is only the concept of Object oriented language like C++,java,VB and etc.

    You can achieve the same thing and can implement also using the STRUCTURE and POINTER concepts in C.You need to move your mind with these concepts and think to implement the interface concept.You can find out very easily.

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    Interface in C programming

    Interface in C++

    C doesn't have any interfaces or classes itself. but interfaces and classes in C can be possible to implemented very easily to simulate .Before starting to do anything I should describe first what is the interfaces and how it's performed and implemented in C++.

    An interface characterize the functionality or capabilities of a defined class without any implementation.The interface shows a contract between a provider and its users.

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Interface in C++ programming

    Interface in C++ programming

    Actually the interface is used and created with the programming languages which provides the environment of object oriented programming.

    The constuction of interface would be as follows and the same rule would be applied with the C interface but the method of definitions would be different-

    Code:
    class Comp
    {
    public:
    
    virtual int compareTo(void* val1) = 0;
    
    };
    
    
    class Fbar: public Comp
    {
    public:
    
    virtual int compareTo(void*val1) 
    
    { /*compare implementation here */ }
    
    };

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Interface in C programming

    The same concept and procedure can be applied which is suggested by Reegan for creation and implementation of interface in the C++, C also follow the same the procedure of defining the structure which is an user defined data type in C programming.


    An example of creating Interface in c language would be as follows -

    Code:
    struct Comp
    {
    
    int (*compareTo)(void* num1) = 0;
    
    };
    
    struct Fbar
    {
    
    int (*compareTo)(void* num1);
    
    int val1;
    int val2;
    int val3;
    
    };
    
    void InitFbar(struct Fbar* this)
    {
    
    this->compareTo = ;
    
    this->val1= 0;
    this->val2 = 1;
    this->val3 = 2;
    
    }

Similar Threads

  1. Replies: 7
    Last Post: 22-10-2011, 10:35 PM
  2. What is Application Programming Interface ( API ) ?
    By Tarjan in forum Networking & Security
    Replies: 5
    Last Post: 28-03-2010, 04:57 AM
  3. Application programming interface technique
    By Fragman in forum Technology & Internet
    Replies: 4
    Last Post: 16-03-2010, 06:31 PM
  4. Replies: 3
    Last Post: 13-12-2008, 01:49 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,502,292.22458 seconds with 17 queries