Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class?
I don't think you can. Think about it: Wouldn't that class inside the class, also have a class inside the class? Which would also have a class inside the class. etc. etc. etc. If you want different things to have different members, they have to be different structures.
This doesn't even work in C. Observe:
will give an error since you can't nest that way.
You can cheat by using a pointer. The compiler will let you make pointers to incomplete types since a pointer's always the same size.
That way it only allocates the size of the pointer, not the entire struct, avoiding the infinite recursion. This means you have to explicitly allocate memory to it later to use it, of course.
Hello,
i am using the sigaction function to handle the SIGCHLD signal.Is it possible to use a class member function as the handler function (the sa_handler member of the sigaction structure)?
The function's signature is:
void (*sa_handler)(int);so i don't think i can use a static member function... (2 Replies)
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)
I have the following class and thought that when I call the set command to set a member, I always use value. Would that be fine?
class ModMisfit {
protected:
Real dtau;
Real mdacc;
Real mindist;
bool hw;
Source** src;
public:
void ... (7 Replies)
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)
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)
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)
There is base class B, and two derived classes D1 and D2 derived from Base. Base class B, have two data members ( public or protected or private or if any). D1 should inherit both these data members, and D2 should be deriving only one member from Base class. Is this kind of design possible without... (1 Reply)
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
LEARN ABOUT CENTOS
struct_class
STRUCT CLASS(9) Device drivers infrastructure STRUCT CLASS(9)NAME
struct_class - device classes
SYNOPSIS
struct class {
const char * name;
struct module * owner;
struct class_attribute * class_attrs;
struct device_attribute * dev_attrs;
const struct attribute_group ** dev_groups;
struct bin_attribute * dev_bin_attrs;
struct kobject * dev_kobj;
int (* dev_uevent) (struct device *dev, struct kobj_uevent_env *env);
char *(* devnode) (struct device *dev, umode_t *mode);
void (* class_release) (struct class *class);
void (* dev_release) (struct device *dev);
int (* suspend) (struct device *dev, pm_message_t state);
int (* resume) (struct device *dev);
const struct kobj_ns_type_operations * ns_type;
const void *(* namespace) (struct device *dev);
const struct dev_pm_ops * pm;
struct subsys_private * p;
};
MEMBERS
name
Name of the class.
owner
The module owner.
class_attrs
Default attributes of this class.
dev_attrs
Default attributes of the devices belong to the class.
dev_groups
Default attributes of the devices that belong to the class.
dev_bin_attrs
Default binary attributes of the devices belong to the class.
dev_kobj
The kobject that represents this class and links it into the hierarchy.
dev_uevent
Called when a device is added, removed from this class, or a few other things that generate uevents to add the environment variables.
devnode
Callback to provide the devtmpfs.
class_release
Called to release this class.
dev_release
Called to release the device.
suspend
Used to put the device to sleep mode, usually to a low power state.
resume
Used to bring the device from the sleep mode.
ns_type
Callbacks so sysfs can detemine namespaces.
namespace
Namespace of the device belongs to this class.
pm
The default device power management operations of this class.
p
The private data of the driver core, no one other than the driver core can touch this.
DESCRIPTION
A class is a higher-level view of a device that abstracts out low-level implementation details. Drivers may see a SCSI disk or an ATA disk,
but, at the class level, they are all simply disks. Classes allow user space to work with devices based on what they do, rather than how
they are connected or how they work.
COPYRIGHT Kernel Hackers Manual 3.10 June 2014 STRUCT CLASS(9)