Question

which is incorrect? struct myStruct { int i; double d; }; class myClass { public: int...

which is incorrect?

struct myStruct

{

int i;

double d;

};

class myClass

{

public:

int i;

double d;

};

myStruct a;

a.i = 3;

myClass b;

b.i = 3;

a) All these statements will compile with no problem.

b) A structure member is accessed using the index operator [ ], with the member name as index. [ ]

c) A class is a type similar to a structure type that normally has member functions as well as member variables.

d) The following definition of the structure variables of type myStruct s and t could be made using several definitions using the structure tag.

struct myStruct

{

int i;

double d;

} s, t;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The incorrect statement out of given options is: All these statements will compile with no problem.

  • Because, members of a struct are public but members of a class are by default private.
  • For Class, members which are preceded by the keyword "public" are public.
Add a comment
Know the answer?
Add Answer to:
which is incorrect? struct myStruct { int i; double d; }; class myClass { public: int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • public class q2 { public double d; public q2(double d) { this.d = d; } public...

    public class q2 { public double d; public q2(double d) { this.d = d; } public double calculate(int i) { if (i < 0) { double m = i * ; * d; System.out.println("d (calculate) == " + d); } else { d = i * d; System.out.println("d (calculate) == " + d); } return d; } The following classes named q2 and test are given. What is the value of the variable resA after successfully running the program? public...

  • In the Quiz class, the foo method has the following API: public double foo(int i, String...

    In the Quiz class, the foo method has the following API: public double foo(int i, String s, char c) What is the return type of the method foo? Int, Double, Char, String

  • C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array...

    C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...

  • tx,y) printf('"Xd %d\n",x,y); void stutt (int a, int b) ( Type Definitions (5 POINTS EACH) 1....

    tx,y) printf('"Xd %d\n",x,y); void stutt (int a, int b) ( Type Definitions (5 POINTS EACH) 1. define a stack type that points to a stacknode" structure for s stack that will manipulate real mumbers Strud steck no de int data shiud stackrode米nett, det Shudt stacknode toct nodej a single real number, respectively 2. define a tarver type that consists of two parts ("partl" and "part2") which contain an aray of 5 integgrs snd tyhedeb strut twver int arod I51 aYrOL...

  • The following program contains the definition of a class called List, a class called Date and...

    The following program contains the definition of a class called List, a class called Date and a main program. Create a template out of the List class so that it can contain not just integers which is how it is now, but any data type, including user defined data types, such as objects of Date class. The main program is given so that you will know what to test your template with. It first creates a List of integers and...

  • Java please answer A to I please dont type the answer on paper please use the...

    Java please answer A to I please dont type the answer on paper please use the computer A.   Explain why alpha cannot be accessed by other members of its class. B.   In the program, how can you determine the type of access modifier? C.   Describe the differences and similarities of beta and gamma in program, within the context of access specifiers and class member accessibility. D.   Explain how objects, a and b, are passed to the method. E.    Why...

  • C++ programming implement a struct int Container similar to C++’s standard template library std::vector but without using Object Oriented Programming.

    Assignment Description: We will implement a struct int Container similar to C++’s standard template library std::vector but without using Object-Oriented Programming. The Container struct will only have member variables and user-defined helper functions that will assist with constructing and destructing instances of the Container type, and to add items to the Container, check the length of the Container, etc. See below for function prototypes and descriptions. User-Defined Helper-Functions and Container Member Variables The helper-functions that operate on the Container data type...

  • For the following code, which statement is not true? Class Point {     private:         double...

    For the following code, which statement is not true? Class Point {     private:         double y;         double z;     public:         double x; }; a.z is available to objects of type Point declared outside the class. b.x is available to objects of type Point declared outside the class. c.x, y, and z are called members variables of the class. d.The name of the class is Point. Given the code below, What is the most accurate description of AwesomeClass(AwesomeClass...

  • Header file for the Rational class: #ifndef RATIONAL_H #define RATIONAL_H class Rational { public: Rational( int...

    Header file for the Rational class: #ifndef RATIONAL_H #define RATIONAL_H class Rational { public: Rational( int = 0, int = 1 ); // default constructor Rational addition( const Rational & ) const; // function addition Rational subtraction( const Rational & ) const; // function subtraction Rational multiplication( const Rational & ) const; // function multi. Rational division( const Rational & ) const; // function division void printRational () const; // print rational format void printRationalAsDouble() const; // print rational as...

  • /* FILE: ./shapes7/shape.h */ #include <iostream> using std::ostream; class shape{ int x,y; public: shape( ) {...

    /* FILE: ./shapes7/shape.h */ #include <iostream> using std::ostream; class shape{ int x,y; public: shape( ) { x=y=0;} shape(int xvalue, int yvalue); void setShape(int new_x, int new_y); void setX(int new_x); void setY(int new_y); int getX( ) const; int getY( ) const; virtual void move(int x, int y) = 0; virtual void shift(int dx, int dy) = 0; virtual void draw( ) = 0; virtual void rotate(double r) = 0; virtual void print(ostream&)const; friend ostream & operator<<(ostream & os, const shape& s);...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT