@grahamdearsley
Forum Replies Created
-
AuthorPosts
-
I didn’t get the letter with my code so I went to the census website and they sent me a new code via a text message, i’m not sure how secure that is because they just sent the text to the number I gave them.
I filled out the form on my phone too and it wasn’t difficult because they have a mobile version of their website.
I put up a flame bait post on Stack Overflow, asking why their members were so mean to obvious beginners, closing their questions and denying ME a chance to answer them. I said that maybe they should spend a couple of minutes analysing the question instead of 2 seconds matching it with a site rule that it broke.
The steam of venom that recieved was beyond even my expectations 😆
Not quite the same thing but my Mum showed me a text on her phone this morning saying that someone had tried to send her cash via her mobile number. It was ME ! but she hasn’t signed up for that service so I had to send it via my registered payees and their account details instead.
My system is getting on a bit and it only has UEFI v2.0 framework. W7 installed in UEFI mode just fine but W10 would not. I searched for a reason for days, off and on, and finally found the bit about W10 requiring v2.3
The main reason for needing v2.3 is W10’s system and device firmware update module, this requires the UEFI firmware query and update functions which didn’t exist before v2.3
W10 now requires your system to support the UEFI v2.3 framework or it will only attempt to install in CSM mode.
I don’t see why your gfx card would affect CSM unless it no longer included the VGA BIOS option rom code and I haven’t seen one that doesn’t yet.
Maybe your new UEFI has just decided to drop CSM support, after all it is only required for installing a non UEFI aware OS like DOS.
I ask because if you had had a copy of VS installed then I could have just posted links to solution.sln files instead of copying and pasting in their various .h and .cpp bits 😃
I think C# may be in trouble, MS would still LIKE us to use it because it limits what us naughty programmers can do but mostly people actually used it so they could access the Windows runtime components for building a GUI.
C++/WinRT allows C++ to access runtime components in the same way a managed language can.
Do you have Visual Studio installed anywhere Ed ?
Most of that is also explained (briefly) in the C++ primer book so, although I CAN now make overloading the “<<” operator work for my classes, I think I will just keep doing what I was doing, include a “print” function as a member of the class. I can then use “class object name”.print anywhere in the scope where I created the object (most often main()) and no overloading is required.
As is not unusual, I was actually wrong about having to declare a separate operator overloading function for each class instance. The class instance name declared in the function is confined to its scope and a new reference for it is created for every new class object you create. It was just unfortunate that the example in my book used the same name as the class object they created.
I have been looking at providing my classes with overloaded operators but it turns out they are of limited use. I am especially interested in the “<<” output operator.
You cant just do “cout << MyClass;” because the “<<” operator wont have a clue what members of your class you want printed of how to format the output.
The solution is to provide a special operator overload function that starts with the keyword “operator” and follows it with a function name which must be of the form “operator” followed by the operator symbol, so in this case “operator<<” (no space). I wont bore you with the details but eventually you end up defining the data members you want printing (it can only handle data members, it can’t call functions) and how you want them printed.
The function must be external to the class definition so it must be declared a “friend” within the class so it can access private members. The reason this function must be external is also the reason it is of limited use.
Every operator overloading function names a particular instance of a class so it must be in the same scope as that instance. You can put your class declaration in a header file and include it in your main.cpp (as you should) but you will be creating named instances of that class in main() so the operator overloading function for that instance has to go in main() too.
Now if you have a class called “Student” and an instance of it called “StudentOne” then you really can write:
cout << StudentOne;
You may have spotted an obvious limitation here, if you create another instance of your class with a different name, then you will have to write another operator overload function naming that instance too !
The Met Police are a bit rubbish but there are a couple of questions.
1. Should the lockdown LAW banning mass gatherings of ANY kind still be in place?
Its a complex question but the government thinks it should be so it is.
2. What do you do with people who break the lockdown LAW ?
Heres a hint.
A constructor is a function with the same name as its class. The constructor contains an argument list enclosed by brackets, like any function, followed by a colon and then followed by a list of parameters that are initialised by the arguments. The direct form of initialisation must be used so we enclose the arguments in braces instead of using “=”.
When we create a class object we follow it with a list of arguments and that calls the constructor with the same number of parameters.
Destructors start with a ~ and then the name of the class, they take no arguments but they do have a body so deleting objects created with “new” could be done there.
The destructor in the example is the default so its body is empty.
I just wanted to give an example of a simple class using constructors, so here is one below:
class.h file
class rectangle
{
public://The default constructor. Required if we define any other constructors
rectangle() = default;//Constructor for rectangle created with 3 argumants
rectangle(int initial_width, int initial_hight, int initial_nothing) : width{ initial_width }, hight{ initial_hight }, nothing{ initial_nothing } {}int get_area()
{
return width * hight;
}int get_width() { return width; }
int get_hight() { return hight; }
int nothing = 10;
~rectangle() {}
private:
int width = 0;
int hight = 0;
};
main.cpp file
#include<iostream>
#include “class.h””
using namespace std;
int main()
{
//Create rectangle object with the default constructor
rectangle test{};int a = test.get_area();
int h = test.get_hight();
int w = test.get_width();//Prints 0 0 0 10
cout << a << ” ” << h << ” ” << w << ” ” << test.nothing << endl;// Create rectangle object using the constructor that takes 3 arguments {int width, int hight, int nothing)
rectangle test1{ 4, 5, 100 };// All functions are public so I can use the dot operator
int a1 = test1.get_area();
int h1 = test1.get_hight();
int w1 = test1.get_width();//”nothing” is public so this is fine too
//Prints 20 4 5 100
cout << a1 << ” ” << w1 << ” ” << h1 << ” ” << test1.nothing << endl;//”hight” is private so I can’t do this
//cout << test.hight << endl;}
See if you can pick the bones out of that 🙂
I am new to smart pointers and I am still struggling with the various types of constructor/destructor that a class can contain but I would have said that you could not use malloc with a smart pointer because the smart pointers default destructor relies on the objects type to do its work.
However I have been reading that there are ways and means around the problem, I am looking into it 😁
He is one of the few interviewers that WILL point out to people that they are talking nonsense, almost all the others just sit there smiling and nodding as their guest spouts the drivel they came on to spout.
Out of interest, Microsoft supplies a class driver for WiFi devices and it comes with Windows. The class driver will work at a basic level with ALL WiFi devices so manufacturers only have to supply a mini driver to support any special features their device supports. Unfortunately power saving modes often come under the heading of special features 🙄
Speccy and HWINFO may both be correct. Qualcomm Atheros is the name of the company and they make an OEM WiFi module for Dell called the Dell Wireless 1502. Unfortunately Dell is responsible for supplying the driver for it so if it’s faulty, and you already have the latest version, then there’s nothing you can do.
I was wrong about the safeness of using “new” within a class.
If you create a pointer to a class type within a class then when the class goes out of scope then the pointer is implicitly destroyed and the destructor for the object it pointed to is called to destroy that as well.
However, the built in types do not have destructors so if you create a pointer to a built in type, an int say, and you fail to delete it before the class goes out of scope, then the pointer will still be implicitly destroyed but the object it pointed to will not. This leaves an object in memory with no pointer referring to it and so no way to delete it.
The solution to the problem is to use a “smart” pointer. A smart pointer is a class object so it has a destructor that destroys the objects it points to when it goes out of scope ( well a unique pointer does, a shared pointer keeps a reference count to its object and only deletes it when the count goes to zero).
Not really C++ but if you fancy having a go with the new Windows Terminal then type it into the search bar and download it from the Windows store.
The Terminal window opens with Power Shell running but you can type CMD.EXE to launch that if you like.
Still not entirely sure that Harry IS Charles’s son.
Would be amusing if the results of a secret DNA test the palace had done when he was born showed up and proved he wasn’t 🤔
-
AuthorPosts
