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

Recommended Answers

All 5 Replies

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

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

why do we extends from these kind of functions

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.

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.