c++ - 如何用文件的类型初始化一个类
问题描述
我是一个初学者,我不知道如何处理这个任务:
*This class is intended to be instantiated with a src character string as a parameter of its constructor. It must then: *-> Determine the type of file to which src corresponds (among: image, video, security plan [.mps]), using the extension *-> Check if the file corresponding to src exists. *-> If the file does not exist, the src member variable of File is initialized with a path to a file by default, depending on the type *(if the desired file was an image, src will contain the path to an "Error" image, ditto for videos and mps).
在 File.h 中:
class File{
private:
string src;
string type;
public:
string description;
File();
File(string src);
~File();
bool exists();
};
在 File.cpp 中:
File::File(string src):src(src){}
bool File::exists(){}
问题是我不知道如何从字符串中检查文件的扩展:/。
解决方案
推荐阅读
- jwt - 带有 RS256 加密 JWT 的 PostGraphile“无效算法”错误
- .net-core - ws-federation dotnet core 没有对 wsignoutcleanup1.0 做任何事情
- sql - 如何显示由于服务更改而重复的值的单个项目列表
- excel - VBA中的Countif函数与动态标准
- c++ - 这两个函数的操作顺序是什么
- sql - 在 MS ACCESS 中使用 SELF JOIN 对多列求和
- snowflake-cloud-data-platform - Snowflake 是否在集群中的多个节点或单个节点上执行“单个”单个查询?
- css - 下拉导航
- c# - C#格式双重限制有效数字但限制科学记数法
- javascript - 在 Javascript 中查询深层嵌套元素