sizeof(char)
?
sizeof(int)
?
sizeof(double)
?
x
in
class A { protected: static int x; };
double a, *b, **c; b = &a; c = & b; **c = 1.2;
void p(const int &x); p(3);
double
that takes a value (of any
type) and returns that value added to itself without changing the
value. Write a fragment of code applying double
to some
declared, initialize variable, where the type of the variable is in
namespace std
.
names
that is an
array of pointers to std::string
values. Allow up to 20
names. Set the first name to your own name, but all of the rest should
be nullptr
.
struct
to create an array that is passed by
value.
void dosomething(int
nums[]);
and write int s = sizeof(nums);
in the
body. What does this set s
to? Is there a way to change
the declaration of nums
so s
gets a different
value?
Circle
with an x, y coordinate for the
center and a radius in centimeters. Include methods to return each
coordinate and the area. Write a class Disk
which is derived
from Circle
and adds a color (represented as an
integer). Add a method to return the color. All methods
of Circle
should be public
in Disk
as well.
Fraction
that takes a numerator
and denominator, both of the same type, and has methods to return the
numerator and denominator as well as a method to_double
that
returns the fraction as a double
. For example
Fraction<short> x(3, 4); cout << "x: " << x.numerator() << '/' << x.denominator << ", value " << x.to_double();would print
x: 3/4, value 0.75
auto x = a;
vs. x = b;
.
while ( ! eof ) { read; process }is a bad idea
doit
if doit
reads files p
and q
and generates r
strdup
, a function which takes a null-terminated
tring and returns a fresh copy of the string. For example
char name[] = "Francis"; char *alt_name = strdup(name); alt_name[4] = '\0'; printf("Full: %s, shortened: %s\n", name, alt_name);would print "Full: Francis, shortened: Fran". Use
malloc
and strcpy
(and possibly other functions) in your answer.