Sponsored Content
Top Forums Programming Writing C++ class and member functions Post 302637349 by kristinu on Tuesday 8th of May 2012 08:39:54 PM
Old 05-08-2012
Looking for a naming convention that resolves the problem of finding reasonable variable names for setter methods and constructors.

---------- Post updated at 05:48 PM ---------- Previous update was at 05:44 PM ----------

Quote:
Originally Posted by Corona688
They're not really the same value, some are capitalized, some aren't.

As long as you have a consistent system for telling which is which and stick to it, it should be maintainable.
Yes, I capitalize member variables, but all inputs to the set functions use the variable name 'value'.

---------- Post updated at 07:39 PM ---------- Previous update was at 05:48 PM ----------

Can one use the same variable name for the class member and the arguments for the setter functions as shown below?

Code:
class ModMisfit {

// -- Attributes -----------------------------------------------------------------------------------

protected:

  static const Real    dflt_dtmin;
  static const Real    dflt_sigma;
  static const Real    dflt_kbeta;
  static const double  dflt_dangsh;
  static const bool    dflt_hw;
  // static const char    DelStr[];
  int     NPhases;
  int     nSources;
  double  dangsh;
  int     iterMax;
  Real    mdacc;
  Real    mindist;
  Real    dtmin;
  Real    sigmaz;
  Real    kbeta;
  bool    hw;
  bool    extrap;
  Source**     srcs;
  List<int>    ds;
  List<int>    dp;
  List<Real>   x;
  List<Real>   t1Lst;
  List<Real>   t2Lst;
  List<Phase>  ph;
  Verbose  vblevel;
  // Real data

// -- Operations -----------------------------------------------------------------------------------

public:

  ModMisfit():                         //
    mindist( -1 ),
    mdacc( -1 ),
    itermax( -1 ),
    dangsh( dflt_dangsh ),
    hw( dflt_hw ),
    extrap( true ),
    dtmin( dflt_dtmin ),
    sigmaz( dflt_sigma ),
    kbeta( dflt_kbeta ),
    vblevel( none ) { }

  void  set_param(                      //
    Parsing&  P );

  void  set_data(                       //
    Parsing&  P );

  void  set_integration(                //
    const Integration  intg );

  void  set_dangsh(                     //
    const double  dang );

  void  set_dtau(                       //
    const Real  dtau );

  void  set_mindist(                    //
    const Real  mindist );

  void  set_itermax(                    //
    const int  itermax );

  void  set_hw(                         //
    const bool  hw );

  Real  get_misfit(                     //
    Velmod*  vm );

  Real  get_pdf(                        //
    Velmod*  vm );

protected:

  void  ResetSrc();                    //

};

 

10 More Discussions You Might Find Interesting

1. Programming

writing functions

I have to write a program in C++ using several functions. The program consists of ticket sales how many if you are an adult, junior, or toddler and if there are any discounts. I have the program working up to the pricing function. when i put the discount in the equation it <strike>do</strike>... (1 Reply)
Discussion started by: ravenswind35
1 Replies

2. Programming

Handling a signal with a class member function

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)
Discussion started by: Zipi
2 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. 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

6. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

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

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

9. Programming

Restricting member of a class non-inheritable in C++

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)
Discussion started by: techmonk
1 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
XConfigureEvent(3)						  XLIB FUNCTIONS						XConfigureEvent(3)

NAME
XConfigureEvent - ConfigureNotify event structure STRUCTURES
The structure for ConfigureNotify events contains: typedef struct { int type; /* ConfigureNotify */ unsigned long serial; /* # of last request processed by server */ Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window event; Window window; int x, y; int width, height; int border_width; Window above; Bool override_redirect; } XConfigureEvent; When you receive this event, the structure members are set as follows. The type member is set to the event type constant name that uniquely identifies it. For example, when the X server reports a GraphicsEx- pose event to a client application, it sends an XGraphicsExposeEvent structure with the type member set to GraphicsExpose. The display member is set to a pointer to the display the event was read on. The send_event member is set to True if the event came from a SendEvent protocol request. The serial member is set from the serial number reported in the protocol but expanded from the 16-bit least-significant bits to a full 32-bit value. The window member is set to the window that is most useful to toolkit dispatchers. The event member is set either to the reconfigured window or to its parent, depending on whether StructureNotify or SubstructureNotify was selected. The window member is set to the window whose size, position, border, and/or stacking order was changed. The x and y members are set to the coordinates relative to the parent window's origin and indicate the position of the upper-left outside corner of the window. The width and height members are set to the inside size of the window, not including the border. The border_width member is set to the width of the window's border, in pixels. The above member is set to the sibling window and is used for stacking operations. If the X server sets this member to None, the window whose state was changed is on the bottom of the stack with respect to sibling windows. However, if this member is set to a sibling window, the window whose state was changed is placed on top of this sibling window. The override_redirect member is set to the override-redirect attribute of the window. Window manager clients normally should ignore this window if the override_redirect member is True. SEE ALSO
XAnyEvent(3), XButtonEvent(3), XCreateWindowEvent(3), XCirculateEvent(3), XCirculateRequestEvent(3), XColormapEvent(3), XConfigur- eRequestEvent(3), XCrossingEvent(3), XDestroyWindowEvent(3), XErrorEvent(3), XExposeEvent(3), XFocusChangeEvent(3), XGraphicsEx- poseEvent(3), XGravityEvent(3), XKeymapEvent(3), XMapEvent(3), XMapRequestEvent(3), XPropertyEvent(3), XReparentEvent(3), XResiz- eRequestEvent(3), XSelectionClearEvent(3), XSelectionEvent(3), XSelectionRequestEvent(3), XUnmapEvent(3), XVisibilityEvent(3) Xlib - C Language X Interface X Version 11 libX11 1.3.2 XConfigureEvent(3)
All times are GMT -4. The time now is 02:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy