We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,307 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

general in c++ and java

in java we use import javax.swing when we want to use frame and panel we write like this

class frame extends jframe

but in c++ we use <iostream.h> and <conio.h> where we use cin and cout from these libraray functions but we dont inherit anything .we use normally we dont write like class base:public derieved there is no inheriting property

3
Contributors
5
Replies
21 Hours
Discussion Span
10 Months Ago
Last Updated
6
Views
rithish
Posting Whiz in Training
268 posts since Apr 2011
Reputation Points: 23
Solved Threads: 9
Skill Endorsements: 0

Not sure what your point is here. Is there a question?

JamesCherrill
... trying to help
Moderator
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33

my aim of question is in normal c++ programming we dont inherit it .it automatically but even in java packages like import java.io we dont inherit anything.but why we use extends jframe in import javax.swing i dont know how its functions

rithish
Posting Whiz in Training
268 posts since Apr 2011
Reputation Points: 23
Solved Threads: 9
Skill Endorsements: 0

why do we extends from these kind of functions

rithish
Posting Whiz in Training
268 posts since Apr 2011
Reputation Points: 23
Solved Threads: 9
Skill Endorsements: 0

import is just a way to simplify referring to classes. You can write
javax.swing.JFrame myFrame = new javax.swing.JFrame();
... but that gets very tedious, so you import javax.swing.* then you can just refer to JFrame and the compiler knows where to find it.

extends is completely different - that says that your class will inherit variables and methods from the parent class.

JamesCherrill
... trying to help
Moderator
8,667 posts since Apr 2008
Reputation Points: 2,636
Solved Threads: 1,476
Skill Endorsements: 33

but in c++ we use <iostream.h> and <conio.h> where we use cin and cout from these libraray functions but we dont inherit anything .we use normally we dont write like class base:public derieved there is no inheriting property

Yes, you can write OO programming in C++ as well. Even though, C++ is not really designed for OO programming, you should be able to do it. I had to write code that way all the time in school -- create a class and use it in another class or program. In C++, inheritant is not explicit. In other words, you have to do some work around, but you could still produce similar effect as inherited class (for both extends & implement). Not intuitive but possible.

When you use include <iostream.h>, it is similar to Java "import java.lang" but you don't explicitly do it in because Java automatically includes that library (for standard IO -- System).

Taywin
Posting Maven
2,633 posts since Apr 2010
Reputation Points: 275
Solved Threads: 376
Skill Endorsements: 17

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0782 seconds using 2.67MB