Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners making consistency of data member in the whole programme without using static keyword

Have Programming Question? Ask it here!
 
 
 


vivek
making consistency of data member in the whole programme without using static keyword
0 Answer(s)      2 years ago
Posted in : Java Beginners


In the below programme i use one boolean variable named check , which is being accessed inside main function by two objects of Tst1 and Test2 . But the value of check variable is not maintained in the programme . we can use static but i want to know some alternative way ..could anyone give me some hints on it ? Thanks in advance .

Inside jointdeatils.h

#pragma once

class Jointdetails
{
public:
    Jointdetails(void);
    ~Jointdetails(void);
    bool check;


};

Inside jointdeatils.cpp

#include "Jointdetails.h"

Jointdetails::Jointdetails(void)
{
    check = false ;
}

Jointdetails::~Jointdetails(void)
{
}

Inside analyzer.h

#pragma once
#include "Jointdetails.h"
class Analyzer
{
public:
    Analyzer(void);
    Jointdetails* GetJointDetails();
    Jointdetails* m_ptheCTJointDetails;
    ~Analyzer(void);
};

Inside analyzer.cpp

#include "Analyzer.h"
#include "stddef.h"
Analyzer::Analyzer(void)
{
    m_ptheCTJointDetails = new Jointdetails();

}

Analyzer::~Analyzer(void)
{
}
Jointdetails* Analyzer::GetJointDetails()
{

    if(m_ptheCTJointDetails) 
        return m_ptheCTJointDetails;
    else
        return NULL;


}

Inside Test1.h

#pragma once
#include "Analyzer.h"
class Tst1
{
public:
    Tst1(void);
    Analyzer *analyzer1 ;
public:
    ~Tst1(void);
};

Inside Test1.cpp

#include "Tst1.h"

Tst1::Tst1(void)
{
    analyzer1 = new Analyzer ;
}

Tst1::~Tst1(void)
{
}

Inside Test2.h

#pragma once
#include "Analyzer.h"
class Test2
{
public:
    Test2(void);
    Analyzer *analyzer2 ;
public:
    ~Test2(void);
};

Inside Test2.cpp

#include "Test2.h"

Test2::Test2(void)
{
    analyzer2 = new Analyzer ;
}

Test2::~Test2(void)
{
}

Inside main.cpp

#include "Test2.h"
#include "Tst1.h"
#include "stdio.h"

int main()
{
    Tst1 *test1 = new Tst1 ; //check = false
    Test2 *test2 = new Test2 ; //check = false
    test1->analyzer1->GetJointDetails()->check = true ;
    if(test2->analyzer2->GetJointDetails()->check )
        printf("Check value is changed");
    else
        printf("Check value is not changed");
        return 0 ;
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check... . But the value of check variable is not maintained in the programme . we can
why using static keyword
why using static keyword  why using static keyword
Advertisements
static keyword in java
.style1 { color: #0000FF; } static keyword in java We are going to discuss about static keyword in java. The static keyword is a special keyword in java programming language. A static member belongs to a class
static keyword
static keyword  please give some detail about Static keyword.   Static Variables Static variables are class variables that are shared... method can access only static data. It can not access non-static data (instance
static keyword
static keyword  Hii, In which portion of memory static variables stored in java. Is it take memory at compile time? thanks deepak mishra
static keyword with real example
static keyword with real example  static keyword with real examplestrong text
avoid using the whole URL
avoid using the whole URL  How can I avoid using the whole URL
how to access the object of one frame on clicking a button without using this keyword
how to access the object of one frame on clicking a button without using this keyword  import java.awt.*; import java.awt.event.*; class Mybuttons1 extends Frame { public static void main(String args[]) { Button b1
static keyword in interface
static keyword in interface  Could any one explain,why static keyword implict (or explict ) come in interface? I asked lot of persons about this question, but nobody did not answered clearly. please explain clearly and say what
Static keyword in public static void main
: static keyword indicates that this method can be invoked simply by using the name... is declared by using static keyword. Following is an example of static declaration...Static keyword in public static void main  Hi, I have seen
static Java Keyword
static Java Keyword       The static is a keyword defined in the java programming language. Keywords... in java programming language likewise the static keyword indicates the following
Access Static Member Of The Class Through Object
Access Static Member Of The Class Through Object  ... that work without any object of the class. Static methods are limited to calling other static methods in the class and to using only static variables
PHP Static Variable and Methods
the method using class, without instantiating any object. Example of PHP Static... should use static methods and variables. Static keyword is used to make only one... of that attribute. Static data are used when some data has to share within
Retriving data from MYSQL without line break using java
Retriving data from MYSQL without line break using java  get data without line breaking from mysql table (i.e data stored as mediumtext )using java
programme
programme  Using an ATM, customer can access their bank accounts... programme to implement a simple ATM for 15 customers. Initially you have to store... using array(s). Then the program ask user to input account number and password
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
demonstrate a) static data members b) static methods
demonstrate a) static data members b) static methods  demonstrate a) static data members b) static methods
How to access sub class member using super class object
How to access sub class member using super class object  class A{ } class B extends A{ int b=1; } class Test{ public static void main(String args[]) { what to do here to access sub class variable b using super class object
static
is applied to member variables, it means that the static variable is shared among all instances of the class. When static is applied to methods, the static keyword...static  what r the main uses of static in java   Hi Friend
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
java programme
java programme   1.....programme for reading 10 values for 10 variables using scanner class 2....declares all types of primitive data inside main method
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use Ajax.We have provided you a link.In that example, with the use of Ajax, we take
without using built-in functions
without using built-in functions  Hai sir... Please help me to solve this... Findout occurances of each string in every another string (built - in functions are not at all allowed) all, and, sand, falling wall and sand
In data structure in java how to parse the given string and counts the member of character that match the given data?
In data structure in java how to parse the given string and counts the member of character that match the given data?  Design a parser that parse the given string and counts the member of character that match the given data.using
using tiles without struts
using tiles without struts  Hi I am trying to make an application using tiles 2.0. Description of my web.xml is as follows: tiles org.apache.tiles.web.startup.TilesServlet
Sorting arraylist without using Collection.sort()
Sorting arraylist without using Collection.sort()  Hi, How can I sort an arraylist without using Collection.sort() nad also I am not allowed to use any other data structure in the program? Is there any algorithm by using which I
messages to the screen without using "document.write()"
messages to the screen without using "document.write()"  To write messages to the screen without using "document.write
Member Classes
. Member classes can also use instances of the same class without explicit delegation. Only the member classes can be declared as static. Local... Member Classes      
Pagination without using database in php
Pagination without using database in php  How can I show multiple images in multiple rows with pagination in php
Making 301 redirection by using <c:redirect>
Making 301 redirection by using   How can i set the status as 301 when using tag? When i use , I am able to redirect to the desired URL (here, Google page) but I get 302 as the status of redirect. I need this status as 301. Any
Static variable in java
. Static variable is accessed without creating object of class using class name...Static variable in java. Static is a keyword in java used to create static...; Classname.variablename; Example: Using Static Variable. public class Staticvariable
static
,then use static blocks and without creation of object we need to perform some task,then go for static methods. If we want variables those values will not be changed...Static Concept  in what are all the situation we may use static
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
call to a member function
call to a member function  While uploading the data on server i am getting following error... call to a member function children
Static Variable
of a class, an object, is created. When static is applied to member variables.... When static is applied to methods, the static keyword means that the specified...Static Variable  What is the basic use of introducing static variable
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
Breaking a string into words without using StringTokenizer
Breaking a string into words without using StringTokenizer  how can we Break a string into words without using StringTokenizer ??   ... { public static void main(String[] args) { Scanner input=new
Add year to Date without using Calendar in java
Add year to Date without using Calendar in java  how could i add a year to a date function without using calendar functions
String length without using length() method in java
String length without using length() method in java  How to count length of string without using length() method in java?   Here is Example... the number of character into the given string without using the length() method
STATIC
STATIC  WHAT IS STATIC BLOCK?EXPLAIN , AND WHAT IS THE DIFFERENCE BETWEEN STATIC BLOCK AND STATIC METHOD?   A STATIC block is automatically... between static block and static method: static block will execute when ever
Calling Static Methods Using SpEL
Calling Static Method Using SpEL Spring 3 provides powerful Expression Language which can be used to wire values into beans properties by calling static method of any bean using SpEL's T() operator. Lets take an example
java programme
java programme   i have to write a java programe that calculates the average of 10 students in Test 1 ,Test 2 and Test 3....Values of the marks in all the test for a student should be hardcore.Ialso have to tell the maixmum
Static
Static  Can i know the real time example for Static method and final variables with defenition? Thank you
static
static  What is the exact need of declaring a variable as static?   A static variable is a variable who's single copy in memory is shared by all objects,so any modifications to the static variable will modify it's value
static
redeclare static variable in the inherited class  can we redeclare static variable in the inherited class like this: public class StaticClass1 { class StaticClass1{ static int noOfInstances; StaticClass1
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
 

 

 

DMCA.com