473,657 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inheriting from a base class and using an interface

I have a class which is implementing an interface, but I also want to have
it inherit from a base class. Can you do both with a class? If so, what's
the syntax?

thanks.
Nov 13 '05 #1
3 18250
public class NewClass : theBase, theInterface
{
//code
}
"Mark" <ma*****@kc.rr. com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
: I have a class which is implementing an interface, but I also want
to have
: it inherit from a base class. Can you do both with a class? If so,
what's
: the syntax?
:
: thanks.
:
:
Nov 13 '05 #2

Awesome. thanks!
"Chris Barrell" <no@spam.com> wrote in message
news:OK******** ********@tk2msf tngp13.phx.gbl. ..
public class NewClass : theBase, theInterface
{
//code
}
"Mark" <ma*****@kc.rr. com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
: I have a class which is implementing an interface, but I also want
to have
: it inherit from a base class. Can you do both with a class? If so,
what's
: the syntax?
:
: thanks.
:
:

Nov 13 '05 #3
Mark,
In addition to Chris's example, you can actually implement multiple
interfaces, but inherit from only one base class.

public class NewClass : theBase, theFirstInterfa ce, theSecondInterf ace
{
//code
}

Hope this helps
Jay

"Mark" <ma*****@kc.rr. com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I have a class which is implementing an interface, but I also want to have
it inherit from a base class. Can you do both with a class? If so, what's
the syntax?

thanks.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
1700
by: JustSomeGuy | last post by:
this doesn't want to compile.... class image : public std::list<element> { element getElement(key k) const { image::iterator iter; for (iter=begin(); iter != end(); ++iter) { element &elem(*iter);
11
2160
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain methods, such as public void Add(MyClass c). How can I enforce the same behavior (of requiring to implement a member with a new return type in an inherited class) in the master class (similar to the CollectionBase)? I have a class called...
2
1828
by: Simon | last post by:
Hi, Just to get started.... I've created a very simple web form, "Simple", using VS and I dropped a HTML img control on the design view. I referenced a picture and it is displayed in browser view. Very simple. I have created a second form and in the code-behind page I have altered the class definition to inherit from, "Simple".
1
336
by: Matthew Roberts | last post by:
Howdy Everyone, I am having trouble understanding the process of creating a type-safe collection by inheriting from the CollectionBase class. I have done it plenty of times, but now that I sit down and look at it, I'm wondering why it behaves the way it does, and also how to improve its functionality. First, understand the basic format of a type-safe collection:
2
1480
by: Charles Law | last post by:
I have a base class - ComponentBase - that inherits from UserControl. My class implements IComponentBase, which defines a minimal set of core properties and methods. All my other components inherit from ComponentBase. I have defined IComponentBase in a common assembly so that my other projects reference this rather than the (large) library that contains the component implementation.
1
1834
by: jbzdak | last post by:
Recently, I have been learning Java (it is one of laboratories on my department), well I know Java is awfully slow, but it is not the point that I'm interested. Java has a keyword "interface. (and if you know what it is skip this paragraph), that is an abstract class, whose every function is public and purely virtual, and every field is public and static. Java has its own reasons for creating that keyword - you can only inherit from one...
0
1219
by: damianmatiasmax | last post by:
Helow, Good days. I am creating a class Base in VB.NET, then I use this class base to create to the class son across inherits, and Then generate the object COM this class son to be used in VB6. The problem is that I do not receive the events of the class base from VB6. I show the code ---------------------------------------------------------------------------------------------------------------- Class Base - Name: A
10
1741
by: Brett Romero | last post by:
Say I have a class inheriting some base class: BaseClass { void Foo() { Update(); } }
4
1691
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 : public virtual base
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.