Sponsored Content
Full Discussion: Purpose of empty Class
Top Forums Programming Purpose of empty Class Post 302227986 by deepthi.s on Friday 22nd of August 2008 11:25:15 AM
Old 08-22-2008
Purpose of empty Class

class A
{};

int main()
{
A a;
}

What is the purpose of such empty classes in C++?Why is it allowed in the language specification?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to find empty folders without using -empty

hi all: my solaris FIND does not support find myFolder -type d -empty how can i find the empty folders? thanks! (7 Replies)
Discussion started by: lasse
7 Replies

2. UNIX for Dummies Questions & Answers

Getting same exit status for empty and non empty file

Hi All, I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both. The value of $? is coming 0 in if part also and else part too. #!/bin/ksh if ]; then echo "data" # exit 0 echo "$?" else... (4 Replies)
Discussion started by: mavesum
4 Replies

3. UNIX for Dummies Questions & Answers

car class (not school class)

im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
Discussion started by: rickym2626
1 Replies

4. Programming

C++ class definition with a member of the same class

Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento) typedef struct elemento { char name; char value; List<struct elemento> ltElementos; ... (7 Replies)
Discussion started by: pogdorica
7 Replies

5. UNIX for Advanced & Expert Users

Purpose of inv

Hi All Can anybody tell me what is the purpose of inv in the below command. ftp -inv $RFTPSERVER /temp/te.txt << EOF and << its stands for what.. Thanks (1 Reply)
Discussion started by: raju4u
1 Replies

6. UNIX for Dummies Questions & Answers

Purpose of <>

Hi, I have read from the book that , <> causes the file to be used as both input as well as output. Can anyone give me the scenario where <> will be useful? Thanks (10 Replies)
Discussion started by: pandeesh
10 Replies

7. Programming

static use for class inside the same class c++

Hi, I believe the next code is wrong: class Egg { Egg e; int i; Egg(int ii=0) : i(ii) {} }; because you would end up with an endless definition (memory allocation) of Egg objects, thus int i. Ok, so God Eckel proposes for a singleton: class Egg { static Egg e; int... (5 Replies)
Discussion started by: xavipoes
5 Replies

8. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

9. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

10. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies
MixinFactory(3pm)					User Contributed Perl Documentation					 MixinFactory(3pm)

NAME
Class::MixinFactory - Class Factory with Selection of Mixins SYNOPSIS
package MyClass; use Class::MixinFactory -hasafactory; sub new { ... } sub foo { return "Foo Bar" } package MyClass::Logging; sub foo { warn "Calling foo"; (shift)->NEXT('foo', @_) } package MyClass::UpperCase; sub foo { uc( (shift)->NEXT('foo', @_) ) } package main; my $class = MyClass->class( 'Logging', 'UpperCase' ); print $class->new()->foo(); # Calls MyClass::Logging::foo, MyClass::UpperCase::foo, MyClass::foo DESCRIPTION
This distribution facilitates the run-time generation of classes which inherit from a base class and some optional selection of mixin classes. A factory is provided to generate the mixed classes with multiple inheritance. A NEXT method allows method redispatch up the inheritance chain. USAGE
The Class::MixinFactory package is just a facade that loads the necessary classes and provides a few import options for compile-time convenience. Factory Interface To generate an object with some combination of mixins, you first pass the names of the mixin classes to a class factory which will generate a mixed class. (Or return the name of the already generated class, if there has been a previous request with the same combination of mixins.) You can add a factory method to your base class, create a separate factory object, or inherit to produce a factory class. Factory Method To add a factory method to a base class, inherit from the Class::MixinFactory::HasAFactory class, or use the "-hasafactory" import option: package MyClass; use Class::MixinFactory -hasafactory; package main; my $class = MyClass->class( 'Logging', 'UpperCase' ); print $class->new()->foo(); Factory Class To create a new class which will act as a factory for another base class, inherit from the Class::MixinFactory::Factory class, or use the "-isafactory" import option: package MyClass::Factory; use Class::MixinFactory -isafactory; MyClass::Factory->base_class( "MyClass" ); package main; my $class = MyClass::Factory->class( 'Logging', 'UpperCase' ); print $class->new()->foo(); Factory Object To create an object which will act as a factory, create a Class::MixinFactory::Factory instance by calling the new() method: use Class::MixinFactory; my $factory = Class::MixinFactory->new(); $factory->base_class( "MyClass" ); my $class = $factory->class( 'Logging', 'UpperCase' ); print $class->new()->foo(); Inheriting from a Mixed Class Inheriting with a Factory Method or Factory Object A subclass can inherit from a mixed class: package MyClass::CustomWidget; @ISA = MyClass->class( 'Logging', 'UpperCase' ); sub foo { local $_ = (shift)->NEXT('foo', @_); tr[a-z][z-a]; $_ } package main; print MyClass::CustomWidget->new()->foo(); Inheriting with a Factory Class A subclass can use a factory class to define its own inheritance: package MyClass::CustomWidget; use Class::MixinFactory -isasubclass, MyClass::Factory => 'Logging', 'UpperCase'; sub foo { local $_ = (shift)->NEXT('foo', @_); tr[a-z][z-a]; $_ } package main; print MyClass::CustomWidget->new()->foo(); Configuring a Factory Factories support methods that control which classes they will use. The base class will be inherited from by all mixed classes. $factory->base_class( "HelloWorld" ); The mixin prefix is prepended to the mixin names passed to the class() method. Mixin names that contain a "::" are assumed to be fully qualified and are not changed. If empty, the base_class is used. $factory->mixin_prefix( 'HelloFeature' ); The mixed prefix is at the start of all generated class names. If empty, the base_class is used, or the factory's class name. $factory->mixed_prefix( 'HelloClass' ); Writing a Mixin Class Writing a mixin class is almost the same as writing a subclass, except where methods need to redispatch to the base-class implementation. (The SUPER::method syntax will only search for classes that the mixin itself inherits from; to search back up the inheritance tree and explore other branches, another redispatch mechanism is needed.) A method named NEXT is provided to continue the search through to the next class which provides a given method. The order in which mixins are stacked is significant, so the caller should understand how their behaviors interact. (See Class::MixinFactory::NEXT.) SEE ALSO
For distribution, installation, support, copyright and license information, see Class::MixinFactory::ReadMe. perl v5.10.1 2009-12-10 MixinFactory(3pm)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy